[FREELDR]

- Use the new realmode code for PxeCallApi, SoftReboot and ChainLoadBiosBootSectorCode
- Remove o386cpi.S from build, the functions are not used
- Use constants for function ids
- Fix a warning

svn path=/trunk/; revision=52284
This commit is contained in:
Timo Kreuzer 2011-06-16 22:11:53 +00:00
parent 2494b475e3
commit 67000c5688
7 changed files with 119 additions and 24 deletions

View file

@ -16,11 +16,8 @@ if(ARCH MATCHES i386)
arch/i386/i386bug.c)
if(NOT MSVC)
list(APPEND FREELDR_BASE64K_SOURCE
arch/i386/boot.S
arch/i386/drvmap.S
arch/i386/i386cpu.S
arch/i386/i386pnp.S
arch/i386/i386pxe.S
arch/i386/linux.S
arch/i386/multiboot.S
arch/i386/mb.S)
@ -32,8 +29,6 @@ elseif(ARCH MATCHES amd64)
if(NOT MSVC)
list(APPEND FREELDR_BASE64K_SOURCE
arch/i386/drvmap.S
arch/i386/i386cpu.S
arch/i386/i386idt.S
arch/i386/i386trap.S
arch/amd64/mb.S)
else()

View file

@ -259,8 +259,8 @@ _Int386:
mov ecx, 9
rep movsd
/* Set the callback index */
mov bx, 0
/* Set the function ID */
mov bx, FNID_Int386
/* Set continue address and switch to real mode */
mov dword ptr [ContinueAddress], offset Int386_return
@ -282,6 +282,86 @@ Int386_return:
ret
/*
* U16 PxeCallApi(U16 Segment, U16 Offset, U16 Service, VOID *Parameter);
*
* RETURNS:
*/
PUBLIC _PxeCallApi
_PxeCallApi:
push ebp
mov ebp, esp
pusha
push es
/* copy entry point */
mov eax, [ebp + 8]
shl eax, 16
mov ax, [ebp + 12]
mov dword ptr ds:[BSS_PxeEntryPoint], eax
/* copy function */
mov ax, [ebp + 16]
mov word ptr ds:[BSS_PxeFunction], ax
/* convert pointer to data buffer to segment/offset */
mov eax, [ebp + 20]
shr eax, 4
and eax, HEX(0f000)
mov word ptr ds:[BSS_PxeBufferSegment], ax
mov eax, [ebp + 20]
and eax, HEX(0ffff)
mov word ptr ds:[BSS_PxeBufferOffset], ax
/* Set the function ID and call realmode */
mov bx, FNID_PxeCallApi
call i386CallRealMode
pop es
popa
mov esp, ebp
pop ebp
mov ax, word ptr [BSS_PxeResult]
ret
PUBLIC _SoftReboot
_SoftReboot:
/* Set the function ID */
mov bx, FNID_SoftReboot
/*Switch to real mode (We don't return) */
jmp SwitchToReal
PUBLIC _ChainLoadBiosBootSectorCode
_ChainLoadBiosBootSectorCode:
/* Set the boot drive */
mov dl, byte ptr [_FrldrBootDrive]
/* Set the function ID */
mov bx, FNID_ChainLoadBiosBootSectorCode
/*Switch to real mode (We don't return) */
jmp SwitchToReal
PUBLIC i386CallRealMode
i386CallRealMode:
/* Set continue address and switch to real mode */
mov dword ptr [ContinueAddress], offset i386CallRealMode_return
jmp SwitchToReal
i386CallRealMode_return:
ret
/* Entrypoint for realmode function calls
* ContinueAddress must be set to the return point from realmode
* bx must be set to the ID of the realmode function to call. */
SwitchToReal:
/* Set sane segments */
mov ax, PMODE_DS

View file

@ -3,7 +3,7 @@
KIDTENTRY DECLSPEC_ALIGN(4) i386Idt[32];
KDESCRIPTOR i386IdtDescriptor = {0, 255, i386Idt};
KDESCRIPTOR i386IdtDescriptor = {0, 255, (ULONG)i386Idt};
static
void

View file

@ -20,18 +20,12 @@ _kernel_pagetable:
PUBLIC _lowmem_pagetable
_lowmem_pagetable:
PUBLIC _ChainLoadBiosBootSectorCode
_ChainLoadBiosBootSectorCode:
PUBLIC _BootOldLinuxKernel
_BootOldLinuxKernel:
PUBLIC _BootNewLinuxKernel
_BootNewLinuxKernel:
PUBLIC _SoftReboot
_SoftReboot:
PUBLIC _DriveMapOldInt13HandlerAddress
_DriveMapOldInt13HandlerAddress:
@ -53,7 +47,4 @@ _PnpBiosGetDeviceNodeCount:
PUBLIC _PnpBiosSupported
_PnpBiosSupported:
PUBLIC _PxeCallApi
_PxeCallApi:
END

View file

@ -102,3 +102,19 @@ SoftReboot:
/* and jump to location FFFF:0 in ROM */
ljmp16 HEX(0FFFF), HEX(0000)
ChainLoadBiosBootSectorCode:
/* Load segment registers */
cli
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, HEX(7C00)
/* Jump to the bootsector code */
ljmp16 HEX(0000), HEX(7C00)

View file

@ -121,10 +121,13 @@ pm_offset:
.word 0 // receives address of PE entry point
.word PMODE_CS
nop
// FIXME: use ljmp16 PMODE_CS:inpmode + hexed 32bit jump
callback_table:
.word Int386
.word SoftReboot
.word ChainLoadBiosBootSectorCode
.word PxeCallApi
/* 16-bit stack pointer */

View file

@ -22,13 +22,23 @@
#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_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_RegisterSet (BSS_START + 16) /* size = 36 */
#define BSS_IntVector (BSS_START + 52)
// next 52
/* Realmode function IDs */
#define FNID_Int386 0
#define FNID_SoftReboot 1
#define FNID_ChainLoadBiosBootSectorCode 2
#define FNID_PxeCallApi 3
/* Layout of the REGS structure */
#define REGS_EAX 0