[FREELDR]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 17 Jun 2011 08:36:49 +0000 (08:36 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 17 Jun 2011 08:36:49 +0000 (08:36 +0000)
- Use new relmode code for PnpBios stuff

svn path=/trunk/; revision=52292

reactos/boot/freeldr/freeldr/arch/i386/i386pnp.S
reactos/boot/freeldr/freeldr/arch/realmode/i386.S
reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc [new file with mode: 0644]
reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc [new file with mode: 0644]
reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h
reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h

index b66b51a..4c5f0b2 100644 (file)
  *
  * RETURNS:
  */
-_pnp_bios_entry_point:
-       .long   0
-_pnp_bios_data_segment:
-       .word   0
-
 PUBLIC _PnpBiosSupported
 _PnpBiosSupported:
 
@@ -82,11 +77,11 @@ pnp_loop:
        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
@@ -104,13 +99,6 @@ pnp_not_found:
  *
  * RETURNS:
  */
-_pnp_result:
-       .long   0
-_pnp_node_size:
-       .word   0
-_pnp_node_count:
-       .word   0
-
 PUBLIC _PnpBiosGetDeviceNodeCount
 _PnpBiosGetDeviceNodeCount:
 
@@ -120,39 +108,16 @@ _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
 
@@ -162,7 +127,7 @@ _PnpBiosGetDeviceNodeCount:
        mov esp, ebp
        pop ebp
 
-       mov eax, _pnp_result
+       mov eax, dword ptr [BSS_PnpResult]
 
        ret
 
@@ -172,14 +137,6 @@ _PnpBiosGetDeviceNodeCount:
  *
  * RETURNS:
  */
-_pnp_buffer_segment:
-       .word   0
-_pnp_buffer_offset:
-       .word   0
-
-_pnp_node_number:
-       .byte   0
-
 EXTERN(_PnpBiosGetDeviceNode)
        .code32
 
@@ -192,54 +149,23 @@ EXTERN(_PnpBiosGetDeviceNode)
        /* 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
@@ -248,7 +174,7 @@ EXTERN(_PnpBiosGetDeviceNode)
        mov esp, ebp
        pop ebp
 
-       mov eax, _pnp_result
+       mov eax, [BSS_PnpResult]
 
        ret
 
index e5522ca..bfa5cde 100644 (file)
@@ -123,11 +123,15 @@ pm_offset:
     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 */
@@ -180,6 +184,8 @@ rmode_idtptr:
 //.org 1024
 
 #include "int386.inc"
+#include "pxe.inc"
+#include "pnp.inc"
 #include "helpers.inc"
 
 .org (FREELDR_PE_BASE - FREELDR_BASE)
diff --git a/reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc b/reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc
new file mode 100644 (file)
index 0000000..d02ce3f
--- /dev/null
@@ -0,0 +1,58 @@
+\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
diff --git a/reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc b/reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc
new file mode 100644 (file)
index 0000000..eae957d
--- /dev/null
@@ -0,0 +1,33 @@
+/*\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
index 3421166..0e4e854 100644 (file)
@@ -71,15 +71,6 @@ VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber);
 /* 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,
index 15e8170..d31a3ce 100644 (file)
 #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 */
@@ -39,6 +47,8 @@
 #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