Convert the config load part to C
authorLiu Aleaxander <Aleaxander@gmail.com>
Wed, 3 Jun 2009 05:14:41 +0000 (13:14 +0800)
committerLiu Aleaxander <Aleaxander@gmail.com>
Wed, 3 Jun 2009 05:14:41 +0000 (13:14 +0800)
For now, I added a temporary file load_config.c that would be merged into
extlinux.c file later, which would make my later work be much easier.

And in order to get rid of the conflict noisy message from the open function
in ui.inc and the open function defined in the unistd.h, I changed the
open in core to core_open. It may be ugly, but it works :)

core/comboot.inc
core/conio.inc
core/extern.inc
core/extlinux.asm
core/getc.inc
core/include/core.h
core/ldlinux.asm
core/parseconfig.inc
core/ui.inc

index 079b476..0710b96 100644 (file)
@@ -1051,5 +1051,7 @@ err_comlarge      db 'COMBOOT image too large.', CR, LF, 0
                section .bss16
                alignb 4
 DOSErrTramp    resd    33              ; Error trampolines
+
+               global ConfigName, CurrentDirName
 ConfigName     resb    FILENAME_MAX
 CurrentDirName resb    FILENAME_MAX
index 5209af1..72443e2 100644 (file)
@@ -208,7 +208,7 @@ msg_viewimage:
                mov si,VGAFileBuf
                mov di,VGAFileMBuf
                call mangle_name
-               call open
+               call core_open
                jz msg_putcharnext              ; Not there
                call vgadisplayfile
                ; Fall through
index e6321d1..0599c30 100644 (file)
@@ -15,4 +15,7 @@
        ; cache.c
        extern cache_init, get_cache_block
 
+       ; load_config.c
+       extern load_config
+
 %endif ; EXTERN_INC
index bdf1cde..f3223e4 100644 (file)
@@ -185,15 +185,7 @@ Files              resb MAX_OPEN*open_file_t_size
 ;
 ; Load configuration file
 ;
-load_config:
-               mov si,config_name      ; Save config file name
-               mov di,ConfigName
-               call strcpy
-               mov dword [CurrentDirName],CUR_DIR_DWORD        ; Write './',0,0 to the CurrentDirName
-               call build_curdir_str
-
-               mov di,ConfigName
-               call open
+               pm_call load_config
                jz no_config_file
 
 ;
index a8d54c7..e74fa12 100644 (file)
@@ -60,7 +60,8 @@ getc_file_lg2 equ 4                   ; Size of getc_file as a power of 2
 ;
 ;              close:  Output: CF set if nothing open
 ;
-open:
+               global core_open
+core_open:
                call searchdir
                jz openfd.ret
 openfd:
index 8e7cd03..574fd7a 100644 (file)
@@ -7,9 +7,16 @@
 extern char core_xfer_buf[65536];
 extern char core_cache_buf[65536];
 
+extern char CurrentDirName[];
+extern char ConfigName[];
+
+
 /* diskstart.inc */
 extern void getlinsec(void);
 
+/* getc.inc */
+extern void core_open(void);
+
 /* hello.c */
 extern void myputs(const char*);
 
index 34eec93..23bc541 100644 (file)
@@ -252,17 +252,17 @@ getfattype:
                mov [CurrentDir],eax    ; ... the current directory
                mov di,syslinux_cfg1
                push di
-               call open
+               call core_open
                pop di
                jnz .config_open
                mov di,syslinux_cfg2
                push di
-               call open
+               call core_open
                pop di
                jnz .config_open
                mov di,syslinux_cfg3
                push di
-               call open
+               call core_open
                pop di
                jz no_config_file
 .config_open:
index 02bc4bf..aecf463 100644 (file)
@@ -161,7 +161,7 @@ pc_opencmd: push ax                         ; Function to tailcall
                call pc_getline
                mov di,MNameBuf
                call mangle_name
-               call open
+               call core_open
                jnz .ok
                pop ax                          ; Drop the successor function
 .ok:           ret                             ; Tailcall if OK, error return
index 3e42a97..5b05536 100644 (file)
@@ -237,7 +237,7 @@ show_help:  ; AX = func key # (0 = F1, 9 = F10, 11 = F12)
                xchg di,ax
                cmp byte [di+NULLOFFSET],NULLFILE
                je short fk_nofile              ; Undefined F-key
-               call open
+               call core_open
                jz short fk_nofile              ; File not found
                call crlf
                call get_msg_file