From 7fc77159cc87c848e8c222951516731b433f9944 Mon Sep 17 00:00:00 2001 From: Liu Aleaxander Date: Wed, 3 Jun 2009 13:14:41 +0800 Subject: [PATCH] Convert the config load part to C 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 | 2 ++ core/conio.inc | 2 +- core/extern.inc | 3 +++ core/extlinux.asm | 10 +--------- core/getc.inc | 3 ++- core/include/core.h | 7 +++++++ core/ldlinux.asm | 6 +++--- core/parseconfig.inc | 2 +- core/ui.inc | 2 +- 9 files changed, 21 insertions(+), 16 deletions(-) diff --git a/core/comboot.inc b/core/comboot.inc index 079b476..0710b96 100644 --- a/core/comboot.inc +++ b/core/comboot.inc @@ -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 diff --git a/core/conio.inc b/core/conio.inc index 5209af1..72443e2 100644 --- a/core/conio.inc +++ b/core/conio.inc @@ -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 diff --git a/core/extern.inc b/core/extern.inc index e6321d1..0599c30 100644 --- a/core/extern.inc +++ b/core/extern.inc @@ -15,4 +15,7 @@ ; cache.c extern cache_init, get_cache_block + ; load_config.c + extern load_config + %endif ; EXTERN_INC diff --git a/core/extlinux.asm b/core/extlinux.asm index bdf1cde..f3223e4 100644 --- a/core/extlinux.asm +++ b/core/extlinux.asm @@ -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 ; diff --git a/core/getc.inc b/core/getc.inc index a8d54c7..e74fa12 100644 --- a/core/getc.inc +++ b/core/getc.inc @@ -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: diff --git a/core/include/core.h b/core/include/core.h index 8e7cd03..574fd7a 100644 --- a/core/include/core.h +++ b/core/include/core.h @@ -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*); diff --git a/core/ldlinux.asm b/core/ldlinux.asm index 34eec93..23bc541 100644 --- a/core/ldlinux.asm +++ b/core/ldlinux.asm @@ -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: diff --git a/core/parseconfig.inc b/core/parseconfig.inc index 02bc4bf..aecf463 100644 --- a/core/parseconfig.inc +++ b/core/parseconfig.inc @@ -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 diff --git a/core/ui.inc b/core/ui.inc index 3e42a97..5b05536 100644 --- a/core/ui.inc +++ b/core/ui.inc @@ -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 -- 2.7.4