aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-07-25 16:52:46 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-07-25 16:52:46 +0800
commit7beadd282123b8e82efae1f9f0703fe05b4d8cb3 (patch)
tree7e55f7f8e08c5690f92625981d597bac23a57f07
parentd63cca07cabc356dbdad2c98269dd350a3593503 (diff)
downloadpxelinux-7beadd282123b8e82efae1f9f0703fe05b4d8cb3.tar.gz
pxelinux-7beadd282123b8e82efae1f9f0703fe05b4d8cb3.tar.xz
pxelinux-7beadd282123b8e82efae1f9f0703fe05b4d8cb3.zip
Core:PXELINUX: memory_scan function converted
-rw-r--r--core/bios.inc1
-rw-r--r--core/extern.inc1
-rw-r--r--core/pxe.c47
-rw-r--r--core/pxelinux.asm45
4 files changed, 52 insertions, 42 deletions
diff --git a/core/bios.inc b/core/bios.inc
index 987a2166..e8d62c7e 100644
--- a/core/bios.inc
+++ b/core/bios.inc
@@ -26,6 +26,7 @@ fdctab2 resw 1
absolute 0400h
serial_base resw 4 ; Base addresses for 4 serial ports
absolute 0413h
+ global BIOS_fbm
BIOS_fbm resw 1 ; Free Base Memory (kilobytes)
absolute 0462h
BIOS_page resb 1 ; Current video page
diff --git a/core/extern.inc b/core/extern.inc
index 440c7b06..262e085d 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -14,6 +14,7 @@
; pxe.c
extern parse_dotquad, is_url, lchexbytes, uchexbytes, is_pxe, is_pxenv
+ extern memory_scan_for_pxe_struct, memory_scan_for_pxenv_struct
; debug.c
extern debug
diff --git a/core/pxe.c b/core/pxe.c
index 00ff6623..af23bc41 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -196,3 +196,50 @@ void is_pxenv(com32sys_t *regs)
regs->eflags.l &= ~EFLAGS_ZF;
}
+
+
+/*********************************************************************
+;
+; memory_scan_for_pxe_struct:
+; memory_scan_for_pxenv_struct:
+;
+; If none of the standard methods find the !PXE/PXENV+ structure,
+; look for it by scanning memory.
+;
+; On exit, if found:
+; ZF = 1, ES:BX -> !PXE structure
+; Otherwise:
+; ZF = 0
+;
+; Assumes DS == CS
+; Clobbers AX, BX, CX, DX, SI, ES
+;
+ ********************************************************************/
+
+inline void memory_scan(uint16_t seg, com32sys_t *regs,
+ void (*func)(com32sys_t *))
+{
+ while (seg < 0xA000 - 1) {
+ regs->es = seg;
+ regs->ebx.w[0] = 0;
+ func(regs);
+ if(regs->eflags.l & EFLAGS_ZF)
+ break; /* found it */
+ seg++;
+ }
+}
+
+void memory_scan_for_pxe_struct(com32sys_t *regs)
+{
+ extern uint16_t BIOS_fbm; /* Starting segment */
+ uint16_t seg = BIOS_fbm << (10 - 4);
+
+ memory_scan(seg, regs, is_pxe);
+}
+
+void memory_scan_for_pxenv_struct(com32sys_t *regs)
+{
+ uint16_t seg = 0x1000;
+
+ memory_scan(seg, regs, is_pxenv);
+}
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 0acfe2ee..54b91b0c 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -333,12 +333,12 @@ _start1:
no_int1a:
; Plan D: !PXE memory scan
inc byte [plan]
- call memory_scan_for_pxe_struct ; !PXE scan
+ pm_call memory_scan_for_pxe_struct ; !PXE scan
je have_pxe
; Plan E: PXENV+ memory scan
inc byte [plan]
- call memory_scan_for_pxenv_struct ; PXENV+ scan
+ pm_call memory_scan_for_pxenv_struct ; PXENV+ scan
je have_pxenv
; Found nothing at all!!
@@ -372,7 +372,7 @@ have_pxenv:
; Nope, !PXE structure missing despite API 2.1+, or at least
; the pointer is missing. Do a last-ditch attempt to find it.
.pxescan:
- call memory_scan_for_pxe_struct
+ pm_call memory_scan_for_pxe_struct
je have_pxe
; Otherwise, no dice, use PXENV+ structure
@@ -849,45 +849,6 @@ kaboom:
jmp 0F000h:0FFF0h ; Reset vector address
;
-; memory_scan_for_pxe_struct:
-; memory_scan_for_pxenv_struct:
-;
-; If none of the standard methods find the !PXE/PXENV+ structure,
-; look for it by scanning memory.
-;
-; On exit, if found:
-; ZF = 1, ES:BX -> !PXE structure
-; Otherwise:
-; ZF = 0
-;
-; Assumes DS == CS
-; Clobbers AX, BX, CX, DX, SI, ES
-;
-memory_scan_for_pxe_struct:
- 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 edx,is_pxenv
- ; fall through
-
-memory_scan_common:
- dec ax ; To skip inc ax
-.mismatch:
- inc ax
- cmp ax,0A000h-1 ; End of memory
- ja .not_found ; ZF = 0 on not found
- mov es,ax
- xor bx,bx
- pm_call edx
- jne .mismatch
-.not_found:
- ret
-
-;
; close_file:
; Deallocates a file structure (pointer in SI)
; Assumes CS == DS.