- Timestamp:
- 04/02/09 21:21:10 (3 years ago)
- Files:
-
- 1 modified
-
Whitix/trunk/devices/pci/pci_bios.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/trunk/devices/pci/pci_bios.c
r1668 r2019 17 17 */ 18 18 19 /* TODO: This code needs checking, if it is ever used. */ 19 20 20 21 #include <i386/ioports.h> … … 27 28 BYTE bios32FarCall[6]; 28 29 29 int PciDetectBios()30 static DWORD PciScanForBios(DWORD start, DWORD end) 30 31 { 31 #if 0 32 DWORD addr=0xE0000,name,temp; 33 BYTE length,sum,revision,err; 34 35 for (;addr < 0xFFFF0; addr+=16) 32 DWORD curr; 33 BYTE length, sum; 34 35 for (curr = start; curr < end; curr += 16) 36 36 { 37 printf("Here, %#X\n", addr); 38 name=*(DWORD*)addr; 39 if (name != 0x5F32335F) 37 if (*(DWORD*)curr != BIOS32_SIGNATURE) 40 38 continue; 41 42 / /Structure length43 length=(*(BYTE*) addr+9)*16;39 40 /* Get the length of the BIOS32 descriptor. It should not be zero. */ 41 length=(*(BYTE*)curr+9)*16; 44 42 45 43 if (length == 0) 46 44 continue; 47 45 46 /* Checksum, to make sure we have a valid BIOS32 descriptor. */ 48 47 for (sum=0; length!=0; length--) 49 sum+=*(BYTE*)((addr+length)-1); 48 sum+=*(BYTE*)((curr+length)-1); 49 50 return curr; 51 } 52 53 return 0; 54 } 50 55 51 *(DWORD*)(bios32FarCall+0)=*(DWORD*)(addr+4); 52 *(WORD*)(bios32FarCall+4)=0x08; 56 int PciDetectBios() 57 { 58 DWORD name,temp; 59 DWORD addr; 60 BYTE revision, err; 53 61 54 asm volatile("mov $0x49435024,%%eax\n" 62 addr = PciScanForBios(0xE0000, 0xffff0); 63 64 if (!addr) 65 { 66 KePrint(KERN_ERROR "PCI: Could not find BIOS32.\n"); 67 return -EINVAL; 68 } 69 70 *(DWORD*)(bios32FarCall+0)=*(DWORD*)(addr+4); 71 *(WORD*)(bios32FarCall+4)=0x08; 72 73 #if 0 74 asm volatile("mov $0x49435024,%%eax\n" 55 75 "mov 0,%%ebx\n" 56 76 "lcall *(%%edi)" 57 77 : "=a"(err), 58 "=b"(addr),59 "=c"(length),60 "=d"(temp)78 "=b"(addr), 79 "=c"(length), 80 "=d"(temp) 61 81 : "D"(&bios32FarCall)); 62 82 63 if (err == 0x80)64 {65 printf("Computer has BIOS32, but no PCI32\n");66 return false;67 }83 if (err == 0x80) 84 { 85 KePrint("PCI: BIOS32 present, but no PCI32\n"); 86 return -EINVAL; 87 } 68 88 69 if (err)70 {71 printf("BIOS32 error = %u\n",(DWORD)err);72 return false;73 }89 if (err) 90 { 91 printf("PCI: BIOS32 error\n"); 92 return -EINVAL; 93 } 74 94 75 95 return true;
