2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/hal/pci
5 * PURPOSE: Interfaces to BIOS32 interface
6 * PROGRAMMER: David Welch (welch@mcmail.com)
12 * NOTES: Sections copied from the Linux pci support
15 /* INCLUDES ***************************************************************/
17 #include <ddk/ntddk.h>
18 #include <internal/mm.h>
19 #include <internal/i386/segment.h>
22 /* TYPES ******************************************************************/
29 unsigned int signature;
32 * Entry point (physical address)
34 unsigned long int entry;
39 unsigned char revision;
42 * Length in paragraphs
47 * Checksum (so all bytes add up to zero)
49 unsigned char checksum;
51 unsigned char reserved[5];
54 BOOLEAN bios32_detected = FALSE;
58 unsigned long address;
59 unsigned short segment;
60 } bios32_indirect = {0,KERNEL_CS};
62 /* FUNCTIONS **************************************************************/
64 #define BIOS32_SIGNATURE (('_' << 0)+('3'<<8)+('2'<<16)+('_'<<24))
67 BOOL static checksum(bios32* service_entry)
69 * FUNCTION: Checks the checksum of a bios32 service entry
71 * service_entry = Pointer to the service entry
72 * RETURNS: True if the sum of the bytes in the entry was zero
76 unsigned char* p = (unsigned char *)service_entry;
80 for (i=0; i<(service_entry->length*16); i++)
84 // DbgPrint("sum = %d\n",sum);
93 BOOLEAN Hal_bios32_is_service_present(ULONG service)
95 unsigned char return_code;
100 __asm__("lcall *(%%edi)"
101 : "=a" (return_code),
107 "D" (&bios32_indirect));
110 return(address+entry);
115 VOID Hal_bios32_probe()
117 * FUNCTION: Probes for an BIOS32 extension
118 * RETURNS: True if detected
121 DbgPrint ("Hal_bios32_probe()\n");
127 for (i=0xe0000;i<=0xffff0;i++)
129 bios32* service_entry = (bios32 *)physical_to_linear(i);
130 if ( service_entry->signature != BIOS32_SIGNATURE )
134 DbgPrint("Signature detected at %x\n",i);
135 if (!checksum(service_entry))
139 DbgPrint("ReactOS: BIOS32 detected at %x\n",i);
140 bios32_indirect.address = service_entry->entry;
141 bios32_detected=TRUE;