*
* RETURNS:
*/
-_pnp_bios_entry_point:
- .long 0
-_pnp_bios_data_segment:
- .word 0
-
PUBLIC _PnpBiosSupported
_PnpBiosSupported:
mov ax, [esi + 15]
shl eax, 16
mov ax, [esi + 0x0D]
- mov _pnp_bios_entry_point, eax
+ mov [BSS_PnpBiosEntryPoint], eax
/* Store bios data segment */
mov ax, [esi + 0x1B]
- mov _pnp_bios_data_segment, ax
+ mov word ptr ds:[BSS_PnpBiosDataSegment], ax
pnp_not_found:
mov eax, edi
*
* RETURNS:
*/
-_pnp_result:
- .long 0
-_pnp_node_size:
- .word 0
-_pnp_node_count:
- .word 0
-
PUBLIC _PnpBiosGetDeviceNodeCount
_PnpBiosGetDeviceNodeCount:
pusha
push es
- call switch_to_real
- .code16
-
- mov ax, word ptr [_pnp_bios_data_segment]
- push ax
-
- push cs
- mov ax, offset _pnp_node_size
- push ax
-
- push cs
- mov ax, offset _pnp_node_count
- push ax
-
- push 0
-
- call dword ptr [_pnp_bios_entry_point]
- add sp, 12
-
- movzx ecx, ax
- mov _pnp_result, ecx
-
-
- call switch_to_prot
- .code32
+ mov bx, FNID_PnpBiosGetDeviceNodeCount
+ call i386CallRealMode
mov esi, [ebp + 8]
- mov ax, _pnp_node_size
+ mov ax, [BSS_PnpNodeSize]
movzx ecx, ax
mov [esi], ecx
mov esi, [ebp + 12]
- mov ax, _pnp_node_count
+ mov ax, [BSS_PnpNodeCount]
movzx ecx, ax
mov [esi], eax
mov esp, ebp
pop ebp
- mov eax, _pnp_result
+ mov eax, dword ptr [BSS_PnpResult]
ret
*
* RETURNS:
*/
-_pnp_buffer_segment:
- .word 0
-_pnp_buffer_offset:
- .word 0
-
-_pnp_node_number:
- .byte 0
-
EXTERN(_PnpBiosGetDeviceNode)
.code32
/* get current node number */
mov esi, [ebp + 8]
mov al, [esi]
- mov _pnp_node_number, al
+ mov [BSS_PnpNodeNumber], al
/* convert pointer to node buffer to segment/offset */
mov eax, [ebp + 12]
shr eax, 4
and eax, 0xf000
- mov _pnp_buffer_segment, ax
+ mov word ptr [BSS_PnpBiosBufferSegment], ax
mov eax, [ebp + 12]
and eax, 0xffff
- mov _pnp_buffer_offset, ax
-
- call switch_to_real
- .code16
-
- /* push bios segment */
- mov ax, word ptr [_pnp_bios_data_segment]
- push ax
-
- /* push control flag */
- push 1
-
- /* push pointer to node buffer (segment/offset) */
- mov ax, word ptr [_pnp_buffer_segment]
- push ax
- mov ax, word ptr [_pnp_buffer_offset]
- push ax
+ mov [BSS_PnpBiosBufferOffset], ax
- /* push pointer to node number (segment/offset) */
- push cs
- mov ax, offset _pnp_node_number
- push ax
-
- /* push function number */
- push 1
-
- /* call entry point */
- call dword ptr [_pnp_bios_entry_point]
- add sp, 14
-
- movzx ecx, ax
- mov _pnp_result, ecx
-
- call switch_to_prot
- .code32
+ mov bx, FNID_PnpBiosGetDeviceNode
+ call i386CallRealMode
/* update node number */
mov esi, [ebp + 8]
- mov al, _pnp_node_number
+ mov al, [BSS_PnpNodeNumber]
mov [esi], al
pop es
mov esp, ebp
pop ebp
- mov eax, _pnp_result
+ mov eax, [BSS_PnpResult]
ret
nop
// FIXME: use ljmp16 PMODE_CS:inpmode + hexed 32bit jump
+
+
callback_table:
.word Int386
.word SoftReboot
.word ChainLoadBiosBootSectorCode
.word PxeCallApi
+ .word PnpBiosGetDeviceNodeCount
+ .word PnpBiosGetDeviceNode
/* 16-bit stack pointer */
//.org 1024
#include "int386.inc"
+#include "pxe.inc"
+#include "pnp.inc"
#include "helpers.inc"
.org (FREELDR_PE_BASE - FREELDR_BASE)
--- /dev/null
+\r
+\r
+PnpBiosGetDeviceNodeCount:\r
+\r
+ mov ax, word ptr [BSS_PnpBiosDataSegment]\r
+ push ax\r
+\r
+ push cs\r
+ mov ax, BSS_PnpNodeSize\r
+ push ax\r
+\r
+ push cs\r
+ mov ax, BSS_PnpNodeCount\r
+ push ax\r
+\r
+ push 0\r
+\r
+ call dword ptr [BSS_PnpBiosEntryPoint]\r
+ add sp, 12\r
+\r
+ movzx ecx, ax\r
+ mov dword ptr [BSS_PnpResult], ecx\r
+\r
+ ret\r
+\r
+\r
+PnpBiosGetDeviceNode:\r
+\r
+ /* push bios segment */\r
+ mov ax, word ptr [BSS_PnpBiosDataSegment]\r
+ push ax\r
+\r
+ /* push control flag */\r
+ push 1\r
+\r
+ /* push pointer to node buffer (segment/offset) */\r
+ mov ax, word ptr [BSS_PnpBiosBufferSegment]\r
+ push ax\r
+ mov ax, word ptr [BSS_PnpBiosBufferOffset]\r
+ push ax\r
+\r
+ /* push pointer to node number (segment/offset) */\r
+ push cs\r
+ mov ax, BSS_PnpNodeNumber\r
+ push ax\r
+\r
+ /* push function number */\r
+ push 1\r
+\r
+ /* call entry point */\r
+ call dword ptr [BSS_PnpBiosEntryPoint]\r
+ add sp, 14\r
+\r
+ movzx ecx, ax\r
+ mov [BSS_PnpResult], ecx\r
+\r
+ ret\r
+\r
--- /dev/null
+/*\r
+ * FreeLoader\r
+ * Copyright (C) 2011 Hervé Poussineau\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License along\r
+ * with this program; if not, write to the Free Software Foundation, Inc.,\r
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+ */\r
+\r
+\r
+PxeCallApi:\r
+\r
+ mov ax, [BSS_PxeBufferSegment]\r
+ push ax\r
+ mov ax, [BSS_PxeBufferOffset]\r
+ push ax\r
+ mov ax, [BSS_PxeFunction]\r
+ push ax\r
+ call dword ptr [BSS_PxeEntryPoint]\r
+ add esp, 6\r
+ mov [BSS_PxeResult], ax\r
+\r
+ ret\r
/* hwpci.c */
VOID DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber);
-/* i386cpu.S */
-ULONG CpuidSupported(VOID);
-VOID GetCpuid(ULONG Level,
- ULONG *eax,
- ULONG *ebx,
- ULONG *ecx,
- ULONG *edx);
-ULONGLONG RDTSC(VOID);
-
/* i386pnp.S */
ULONG_PTR PnpBiosSupported(VOID);
ULONG PnpBiosGetDeviceNodeCount(ULONG *NodeSize,
#define DISKREADBUFFER_SIZE 512
/* These addresses specify the realmode "BSS section" layout */
-#define BSS_RealModeEntry (BSS_START + 0)
-#define BSS_CallbackAddress (BSS_START + 4)
-#define BSS_CallbackReturn (BSS_START + 8)
-#define BSS_RegisterSet (BSS_START + 16) /* size = 36 */
-#define BSS_IntVector (BSS_START + 52)
-#define BSS_PxeEntryPoint (BSS_START + 56)
-#define BSS_PxeBufferSegment (BSS_START + 60)
-#define BSS_PxeBufferOffset (BSS_START + 64)
-#define BSS_PxeFunction (BSS_START + 68)
-#define BSS_PxeResult (BSS_START + 72)
+#define BSS_RealModeEntry (BSS_START + 0)
+#define BSS_CallbackAddress (BSS_START + 4)
+#define BSS_CallbackReturn (BSS_START + 8)
+#define BSS_RegisterSet (BSS_START + 16) /* size = 36 */
+#define BSS_IntVector (BSS_START + 52)
+#define BSS_PxeEntryPoint (BSS_START + 56)
+#define BSS_PxeBufferSegment (BSS_START + 60)
+#define BSS_PxeBufferOffset (BSS_START + 64)
+#define BSS_PxeFunction (BSS_START + 68)
+#define BSS_PxeResult (BSS_START + 72)
+#define BSS_PnpBiosEntryPoint (BSS_START + 76)
+#define BSS_PnpBiosDataSegment (BSS_START + 80)
+#define BSS_PnpBiosBufferSegment (BSS_START + 84)
+#define BSS_PnpBiosBufferOffset (BSS_START + 88)
+#define BSS_PnpNodeSize (BSS_START + 92)
+#define BSS_PnpNodeCount (BSS_START + 96)
+#define BSS_PnpNodeNumber (BSS_START + 100)
+#define BSS_PnpResult (BSS_START + 104)
/* Realmode function IDs */
#define FNID_SoftReboot 1
#define FNID_ChainLoadBiosBootSectorCode 2
#define FNID_PxeCallApi 3
+#define FNID_PnpBiosGetDeviceNodeCount 4
+#define FNID_PnpBiosGetDeviceNode 5
/* Layout of the REGS structure */
#define REGS_EAX 0