diff options
author | hpa <hpa> | 2003-11-26 05:42:33 +0000 |
---|---|---|
committer | hpa <hpa> | 2003-11-26 05:42:33 +0000 |
commit | df2322b51c6ffd9e4a05b225c5c4ba44b09d3e75 (patch) | |
tree | 2e837e97013969748192fddd5bac9515e6b2596d /bootsect.inc | |
parent | 0fab936237d1b5fb713f291dfe6aa7c342c7d246 (diff) | |
download | syslinux-df2322b51c6ffd9e4a05b225c5c4ba44b09d3e75.tar.gz |
Add a bootstrap chainloading API, and include a sample program for it.syslinux-2.08-pre5
Diffstat (limited to 'bootsect.inc')
-rw-r--r-- | bootsect.inc | 91 |
1 files changed, 58 insertions, 33 deletions
diff --git a/bootsect.inc b/bootsect.inc index 24ebab6e..f0dc260f 100644 --- a/bootsect.inc +++ b/bootsect.inc @@ -27,81 +27,106 @@ is_bootsector: %if IS_SYSLINUX || IS_MDSLINUX ; Transfer zero bytes - xor cx,cx + mov byte [CopySuper],0 jmp short load_bootsec + is_bss_sector: ; Transfer the superblock - mov cx,superblock_len -load_bootsec: - push cx + mov byte [CopySuper],superblock_len %endif +load_bootsec: xchg dx,ax shl eax,16 xchg dx,ax ; Now EAX = file length mov edi, 100000h + push edi ; Save load address call load_high call crlf -%if IS_SYSLINUX || IS_MDSLINUX - pop cx -%endif - sub edi,100000h push edi ; Save length %if IS_SYSLINUX || IS_MDSLINUX + movzx ecx,byte [CopySuper] jcxz .not_bss ; For a BSS boot sector we have to patch. mov esi,superblock mov edi,100000h+(superblock-bootsec) - movzx ecx,cx call bcopy .not_bss: %endif -; -; Prepare for shutting down -; - call vgaclearmode + xor edx,edx - xor eax,eax + xor esi,esi %if IS_SYSLINUX || IS_MDSLINUX - mov dl,[bsDriveNumber] + ; Restore original FDC table + mov eax,[OrigFDCTabPtr] + mov [fdctab],eax - mov si,PartInfo + mov dl,[bsDriveNumber] + mov si,PartInfo ; Partition info buffer mov di,800h-18 ; Put partition info here push di mov cx,8 ; 16 bytes + xor ax,ax rep movsw pop si ; DS:SI points to partition info %elif IS_ISOLINUX mov dl,[DriveNo] %elif IS_PXELINUX - ; Close the UDP stack so the PXE stack is in a known state for - ; the new NBP + mov byte [KeepPXE],1 ; Chainloading another NBP call reset_pxe %endif + xor bx,bx - pop ecx ; Byte count to copy +; +; Entrypoint for "shut down and replace bootstrap" -- also invoked by +; the COMBOOT API. This routine expects two dword on the stack: +; linear address and length. Additionally, the values of ESI and EDX +; are passed on to the new bootstrap; the value of BX becomes the new +; DS. +; +replace_bootstrap: + + ; + ; Prepare for shutting down + ; + call vgaclearmode + + ; + ; Set up initial stack frame (not used by PXE if keeppxe is set) + ; + xor ax,ax + mov ds,ax + mov es,ax - cli - xor ebx,ebx - mov ds,bx - mov es,bx %if IS_PXELINUX - lss sp,[InitStack] ; Reset stack to PXE original -%else - mov esp,7C00h - pushfd - pushad - push bx ; ds - push bx ; es - push bx ; fs - push bx ; gs + test byte [KeepPXE],01h + jz .stdstack + les di,[InitStack] ; Reset stack to PXE original + jmp .stackok %endif +.stdstack: + mov di,7C00h-44 + push di + mov cx,22 ; 44 bytes + rep stosw + pop di +.stackok: + + mov [es:di+28],edx + mov [es:di+12],esi + mov [es:di+6],bx - mov esi,100000h ; Copy from... + pop ecx ; Byte count to copy + pop esi ; Copy from... + + cli + mov ax,es + mov ss,ax + movzx esp,di mov edi,7C00h ; Copy to... jmp bcopy_over_self |