When chainloading, set ES:DI to point to the $PnP ICS if available.
authorH. Peter Anvin <hpa@zytor.com>
Tue, 24 Oct 2006 23:40:45 +0000 (16:40 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 24 Oct 2006 23:40:45 +0000 (16:40 -0700)
Arguably these really should be kept from the original invocation instead
of saved.  This is doable for PXELINUX, but might be very hard to do for
the disk-based ones.  Think hard about it.

bootsect.inc

index b1360a5..d52aefb 100644 (file)
@@ -132,10 +132,39 @@ replace_bootstrap:
                pop di
 .stackok:
 
-               mov [es:di+28],edx
-               mov [es:di+12],esi
-               mov [es:di+6],bx
+               mov [es:di+28],edx      ; New EDX
+               mov [es:di+12],esi      ; New ESI
+               mov [es:di+6],bx        ; New DS
 
+               ; Hunt for $PnP header if one exists
+               mov ax,0F000h
+               mov fs,ax
+               xor bx,bx
+.findpnp:
+               cmp dword [fs:bx], "$PnP"
+               jz .foundpnp
+               inc bx
+               jnz .findpnp
+               jmp .donepnp            ; No $PnP header found
+.foundpnp:
+               movzx cx,byte [fs:bx+5] ; Size of $PnP header
+               cmp cl,21h
+               jb .findpnp             ; Invalid $PnP header (too short)
+               push bx
+               xor ax,ax
+.checkpnp:
+               add al,byte [fs:bx]
+               inc bx
+               loop .checkpnp
+               pop bx
+               and al,al
+               jnz .findpnp
+
+               ; Found a valid $PnP header, point ES:DI to it
+               mov [es:di+8], bx       ; New DI
+               mov [es:di+4], fs       ; New ES
+
+.donepnp:
                pop ax                  ; Copy list count
                pop bx                  ; Copy from...