aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-07-25 16:03:12 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-07-25 16:03:12 +0800
commitd63cca07cabc356dbdad2c98269dd350a3593503 (patch)
treebe9c8a72ef5a4ae9cb9345824aa5da8111d61367
parent1c7c987be253ea0be962415ee656ca96c4eae85d (diff)
downloadpxelinux-d63cca07cabc356dbdad2c98269dd350a3593503.tar.gz
pxelinux-d63cca07cabc356dbdad2c98269dd350a3593503.tar.xz
pxelinux-d63cca07cabc356dbdad2c98269dd350a3593503.zip
Core:PXELINUX: is_pxe and is_pxenv converted
-rw-r--r--core/extern.inc2
-rw-r--r--core/pxe.c62
-rw-r--r--core/pxelinux.asm55
3 files changed, 70 insertions, 49 deletions
diff --git a/core/extern.inc b/core/extern.inc
index 886fc5ee..440c7b06 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -13,7 +13,7 @@
extern hello
; pxe.c
- extern parse_dotquad, is_url, lchexbytes, uchexbytes
+ extern parse_dotquad, is_url, lchexbytes, uchexbytes, is_pxe, is_pxenv
; debug.c
extern debug
diff --git a/core/pxe.c b/core/pxe.c
index 4e09a044..00ff6623 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -134,3 +134,65 @@ void uchexbytes(com32sys_t *regs)
regs->edi.w[0] = OFFS_WRT(dst, 0);
regs->ecx.w[0] = 0;
}
+
+
+/**
+ * Validity check on possible !PXE structure in ES:BX
+ *
+ * Return ZF = 1 on success
+ *
+ * Clobbers CX and SI
+ *
+ */
+void is_pxe(com32sys_t *regs)
+{
+ char *p = (char *)MK_PTR(regs->es, regs->ebx.w[0]);
+ int i;
+ uint8_t sum = 0;
+
+ if (strncmp(p, "!PXE", 4))
+ goto bad;
+ i = (int)*(p + 4);
+ if ( i < 0x58)
+ return;
+
+ for (; i > 0; i--)
+ sum += *p++;
+
+ if (sum == 0) {
+ regs->eflags.l |= EFLAGS_ZF;
+ return;
+ }
+
+ bad:
+ regs->eflags.l &= ~EFLAGS_ZF;
+}
+
+/**
+ * Just like is_pxe, it checks PXENV+ structure
+ *
+ */
+void is_pxenv(com32sys_t *regs)
+{
+ char *p = (char *)MK_PTR(regs->es, regs->ebx.w[0]);
+ int i;
+ uint8_t sum = 0;
+
+ if (strncmp(p, "PXENV+", 6))
+ goto bad;
+ i = (int)*(p + 8);
+ if ( i < 0x28)
+ return;
+
+ for (; i > 0; i--)
+ sum += *p++;
+
+ if (sum == 0) {
+ regs->eflags.l |= EFLAGS_ZF;
+ return;
+ }
+
+ bad:
+ regs->eflags.l &= ~EFLAGS_ZF;
+}
+
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 1a3b4531..0acfe2ee 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -301,14 +301,14 @@ _start1:
; Plan A: !PXE structure as SS:[SP+4]
lgs bp,[InitStack] ; GS:BP -> original stack
les bx,[gs:bp+48]
- call is_pxe
+ pm_call is_pxe
je have_pxe
; Plan B: PXENV+ structure at [ES:BX]
inc byte [plan]
mov bx,[gs:bp+24] ; Original BX
mov es,[gs:bp+4] ; Original ES
- call is_pxenv
+ pm_call is_pxenv
je have_pxenv
; Plan C: PXENV+ structure via INT 1Ah AX=5650h
@@ -327,7 +327,7 @@ _start1:
cmp ax,564Eh
jne no_int1a
- call is_pxenv
+ pm_call is_pxenv
je have_pxenv
no_int1a:
@@ -366,7 +366,7 @@ have_pxenv:
cmp byte [es:bx+8],2Ch ; Space for !PXE pointer?
jb .pxescan
les bx,[es:bx+28h] ; !PXE structure pointer
- call is_pxe
+ pm_call is_pxe
je have_pxe
; Nope, !PXE structure missing despite API 2.1+, or at least
@@ -864,14 +864,14 @@ kaboom:
; Clobbers AX, BX, CX, DX, SI, ES
;
memory_scan_for_pxe_struct:
- mov dx,is_pxe
+ mov edx,is_pxe
mov ax,[BIOS_fbm] ; Starting segment
shl ax,(10-4) ; Kilobytes -> paragraphs
jmp memory_scan_common
memory_scan_for_pxenv_struct:
mov ax,1000h ; Starting segment
- mov dx,is_pxenv
+ mov edx,is_pxenv
; fall through
memory_scan_common:
@@ -882,53 +882,12 @@ memory_scan_common:
ja .not_found ; ZF = 0 on not found
mov es,ax
xor bx,bx
- call dx
+ pm_call edx
jne .mismatch
.not_found:
ret
;
-; is_pxe:
-; Validity check on possible !PXE structure in ES:BX
-; is_pxenv:
-; Validity check on possible PXENV+ structure in ES:BX
-;
-; Return ZF = 1 on success
-;
-; Clobbers CX and SI
-;
-is_struc:
-.pxe:
- cmp dword [es:bx],'!PXE'
- jne .bad
- movzx cx,byte [es:bx+4]
- cmp cx,58h
- jae .checksum
- ret
-.pxenv:
- cmp dword [es:bx],'PXEN'
- jne .bad
- cmp word [es:bx+4],'V+'
- jne .bad
- movzx cx,[es:bx+8]
- cmp cx,28h
- jb .bad
-.checksum:
- push ax
- mov si,bx
- xor ax,ax
-.loop:
- es lodsb
- add ah,al
- loop .loop
- pop ax
-.bad:
- ret
-
-is_pxe equ is_struc.pxe
-is_pxenv equ is_struc.pxenv
-
-;
; close_file:
; Deallocates a file structure (pointer in SI)
; Assumes CS == DS.