aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-07-25 14:21:18 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-07-25 14:21:18 +0800
commit8cf560ee07bd14235304c6e8eea360ab9461df19 (patch)
tree79c487873b3aef23ae4bc81e22aec84c4ae0028e
parente5f2e60adbad8b675d6e372792b7d878ef19d5ae (diff)
downloadpxelinux-8cf560ee07bd14235304c6e8eea360ab9461df19.tar.gz
pxelinux-8cf560ee07bd14235304c6e8eea360ab9461df19.tar.xz
pxelinux-8cf560ee07bd14235304c6e8eea360ab9461df19.zip
Core:PXELINUX: convert parse_dotquad function
-rw-r--r--core/extern.inc3
-rw-r--r--core/include/pxe.h5
-rw-r--r--core/pxe.c46
-rw-r--r--core/pxelinux.asm48
4 files changed, 55 insertions, 47 deletions
diff --git a/core/extern.inc b/core/extern.inc
index f765cffe..641b27e4 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -12,4 +12,7 @@
; hello.c
extern hello
+ ; pxe.c
+ extern parse_dotquad
+
%endif ; EXTERN_INC
diff --git a/core/include/pxe.h b/core/include/pxe.h
new file mode 100644
index 00000000..502d7486
--- /dev/null
+++ b/core/include/pxe.h
@@ -0,0 +1,5 @@
+#ifndef PXE_H
+
+
+
+#endif /* pxe.h */
diff --git a/core/pxe.c b/core/pxe.c
new file mode 100644
index 00000000..0bd328c3
--- /dev/null
+++ b/core/pxe.c
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <string.h>
+#include <core.h>
+#include <pxe.h>
+
+#define is_digit(c) ((c >= '0') && (c <= '9'))
+
+/*********************************************************************
+;
+; parse_dotquad:
+; Read a dot-quad pathname in DS:SI and output an IP
+; address in EAX, with SI pointing to the first
+; nonmatching character.
+;
+; Return CF=1 on error.
+;
+; No segment assumptions permitted.
+;
+*********************************************************************/
+void parse_dotquad(com32sys_t *regs)
+{
+ char *pathname = (char *)MK_PTR(regs->ds, regs->esi.w[0]);
+ char *p = pathname;
+ int i = 0;
+ uint8_t part = 0;
+ uint32_t ip = 0;
+
+ for (; i < 4; i++) {
+ while (is_digit(*p)) {
+ part = part * 10 + *p - '0';
+ p++;
+ }
+ if (i != 3 && *p != '.') {
+ regs->eflags.l |= EFLAGS_CF;
+ return;
+ }
+
+ ip = (ip << 8) | part;
+ part = 0;
+ p++;
+ }
+ p --;
+
+ regs->eax.l = ip;
+ regs->esi.w[0] = OFFS_WRT(p, 0);
+}
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 3f7cb8c6..a6f18937 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -1367,52 +1367,6 @@ free_socket:
xor si,si
ret
-;
-; parse_dotquad:
-; Read a dot-quad pathname in DS:SI and output an IP
-; address in EAX, with SI pointing to the first
-; nonmatching character.
-;
-; Return CF=1 on error.
-;
-; No segment assumptions permitted.
-;
-parse_dotquad:
- push cx
- mov cx,4
- xor eax,eax
-.parseloop:
- mov ch,ah
- mov ah,al
- lodsb
- sub al,'0'
- jb .notnumeric
- cmp al,9
- ja .notnumeric
- aad ; AL += 10 * AH; AH = 0;
- xchg ah,ch
- jmp .parseloop
-.notnumeric:
- cmp al,'.'-'0'
- pushf
- mov al,ah
- mov ah,ch
- xor ch,ch
- ror eax,8
- popf
- jne .error
- loop .parseloop
- jmp .done
-.error:
- loop .realerror ; If CX := 1 then we're done
- clc
- jmp .done
-.realerror:
- stc
-.done:
- dec si ; CF unchanged!
- pop cx
- ret
;
; is_url: Return CF=0 if and only if the buffer pointed to by
@@ -1532,7 +1486,7 @@ mangle_name:
.here:
pop si
push si
- call parse_dotquad
+ pm_call parse_dotquad
jc .notdq
cmp word [si],'::'
je .gotprefix