diff --git a/include/asm.h b/include/asm.h index dafa9a9..51949f8 100755 --- a/include/asm.h +++ b/include/asm.h @@ -166,14 +166,14 @@ u16 _v; \ asm volatile ("inw %%dx,%%ax" : "=a" (_v) : "d"(port)); \ _v; \ -} +}) #define ind(port) ({ \ u32 _v; \ asm volatile ("inl %%dx,%%eax" : "=a" (_v) : "d"(port)); \ _v; \ -} +}) /******************************************************************************/ diff --git a/include/pci.h b/include/pci.h new file mode 100755 index 0000000..9a06375 --- /dev/null +++ b/include/pci.h @@ -0,0 +1,14 @@ +/*******************************************************************************/ +/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ +/* */ + +typedef struct pcidev { + union { + struct { + u16 vendor; + u16 device; + }; + u32 dword; + }; +} pcidev __attribute__ ((packed)); + diff --git a/include/shell.h b/include/shell.h index 9dfe1ee..df53bf1 100644 --- a/include/shell.h +++ b/include/shell.h @@ -27,3 +27,4 @@ int bpclr(u8* commandline); int sfont(u8* commandline); int help(); int logo(); +int detectpci(); diff --git a/include/video.h b/include/video.h index e284390..b0c5290 100755 --- a/include/video.h +++ b/include/video.h @@ -11,8 +11,8 @@ #define MAXFONTS 10 typedef struct vertex2d{ - u16 x; - u16 y; + s16 x; + s16 y; } vertex2d __attribute__ ((packed)); typedef struct rgbcolor { @@ -107,9 +107,9 @@ void showchar (u16 coordx, u16 coordy, u8 thechar, u8 attrib); u8 getchar (u16 coordx, u16 coordy); u8 getattrib (u16 coordx, u16 coordy); void v_writepxl (vertex2d *A, u32 color); -void writepxl (u16 x, u16 y, u32 color); -void line(u32 x1, u32 y1, u32 x2, u32 y2, u32 color); -void hline(u16 x1, u16 x2, u16 y, u32 color); +void writepxl (s16 x, s16 y, u32 color); +void line(s16 x1, s16 y1, s16 x2, s16 y2, u32 color); +void hline(s16 x1, s16 x2, s16 y, u32 color); void changemode(u8 mode); u32 egatorgb(u8 ega); u8 egatovga(u8 ega); diff --git a/lib/3d.c b/lib/3d.c index e4ce59e..37f34ba 100755 --- a/lib/3d.c +++ b/lib/3d.c @@ -74,8 +74,8 @@ void cube(model3d *model, vector4 *origin, u16 size) model->facelist[4].V2=1; model->facelist[4].V3=5; model->facelist[5].V1=0; - model->facelist[5].V2=4; - model->facelist[5].V3=5; + model->facelist[5].V2=1; + model->facelist[5].V3=4; model->facelist[6].V1=0; model->facelist[6].V2=0; model->facelist[6].V3=0; diff --git a/lib/pci.c b/lib/pci.c new file mode 100755 index 0000000..2385075 --- /dev/null +++ b/lib/pci.c @@ -0,0 +1,53 @@ +/*******************************************************************************/ +/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ +/* */ + +#include "asm.h" +#include "types.h" +#include "pci.h" + + +#define MAX_BUS_SCAN 256 +#define MAX_DEVICE_SCAN 32 +#define MAX_FUNCTION_SCAN 8 + +/*******************************************************************************/ +/* Detecte s */ + +pcidev getPCIinfo(const u8 bus, const u8 dev, const u8 function) +{ + pcidev result; + const u32 registry = 0; + u32 addr = (0x80000000|(bus << 16)|(dev << 11)|(function << 8)|(registry & 0xFC)); + outd(0xCF8, addr); + result.dword = ind(0xCFC); + if (result.dword == 0xFFFFFFFF) + result.dword = 0x0; + return result; +} + +/*******************************************************************************/ +/* Scan le bus PCI et affiche les périphériques */ + +void scanPCI(void) +{ + u32 i, bus, device, function; + pcidev result; + i = 0; + for (bus=0; busisgraphic) { - if (x2 > x1) + if (x1<0) + { + if (x2<0) + return; + x1=0; + } + else if (x1>vinfo->currentwidth) + x1=vinfo->currentwidth-1; + if (x2<0) + x2=0; + else if (x2>vinfo->currentwidth) + { + if (x1>vinfo->currentwidth) + return; + x2=vinfo->currentwidth-1; + } + if (x1>vinfo->currentwidth) + x1=vinfo->currentwidth-1; + if (x2 > x1) mem_to_video(color,(vinfo->currentdepth>>3)*x1+vinfo->currentpitch*y,x2-x1,false); else mem_to_video(color,(vinfo->currentdepth>>3)*x2+vinfo->currentpitch*y,x1-x2,false); @@ -680,12 +698,15 @@ void v_writepxl(vertex2d *A, u32 color) writepxl(A->x, A->y, color); } -void writepxl(u16 x, u16 y, u32 color) +void writepxl(s16 x, s16 y, u32 color) { if (vinfo->isgraphic) { - u32 addr=(vinfo->currentdepth>>3)*x+vinfo->currentpitch*y; - mem_to_video(color,addr,1,false); + if (x>0 && y>0 && xcurrentwidth && ycurrentheight) + { + u32 addr=(vinfo->currentdepth>>3)*x+vinfo->currentpitch*y; + mem_to_video(color,addr,1,false); + } } } @@ -697,13 +718,79 @@ void v_line(vertex2d *A, vertex2d *B, u32 color) line(A->x, A->y, B->x, B->y, color); } -void line(u32 x1, u32 y1, u32 x2, u32 y2, u32 color) +void line(s16 x1, s16 y1, s16 x2, s16 y2, u32 color) { - s32 dx, dy, sdx, sdy; - u32 i, dxabs, dyabs, x, y, px, py; + s16 dx, dy, sdx, sdy; + float a, b; + s16 i, dxabs, dyabs, x, y, px, py; dx = x2 - x1; /* distance horizontale de la line */ - dy = y2 - y1; /* distance verticale de la line * */ + dy = y2 - y1; /* distance verticale de la line */ + + if (x1<0) + { + a = 1.0f * dy / dx; + b = y1 - a*x1; + x1 = 0; + y1 = b; + if (x2<0) + return; + } + else if (x2<0) + { + a = 1.0f * dy / dx; + b = y2 - a*x2; + x2 = 0; + y2 = b; + } + if (y1<0) + { + a = 1.0f * dy / dx; + b = y1 - a*x1; + y1 = 0; + x1 = - b / a; + if (y2<0) + return; + } + else if (y2<0) + { + a = 1.0f * dy / dx; + b = y2 - a*x2; + y2 = 0; + x2 = - b / a; + } + if (x1>vinfo->currentwidth) + { + a = 1.0f * dy / dx; + b = y1 - a*x1; + x1 = vinfo->currentwidth-1; + y1 = a*x1+b; + if (x2>vinfo->currentwidth) + return; + } + else if (x2>vinfo->currentwidth) + { + a = 1.0f * dy / dx; + b = y2 - a*x2; + x2 = vinfo->currentwidth-1; + y2 = a*x2+b; + } + if (y1>vinfo->currentheight) + { + a = 1.0f * dy / dx; + b = y1 - a*x1; + y1 = vinfo->currentheight-1; + x1 = (y1 - b) / a; + if (y2>vinfo->currentheight) + return; + } + else if (y2>vinfo->currentheight) + { + a = 1.0f * dy / dx; + b = y2 - a*x2; + y2 = vinfo->currentheight-1; + x2 = (y2 - b) / a; + } dxabs = abs(dx); dyabs = abs(dy); sdx = sgn(dx);