Add 32-bit versions of open file/close file
[profile/ivi/syslinux.git] / core / comboot.inc
index 57e631e..7e4c3d6 100644 (file)
@@ -63,7 +63,7 @@
 
 ; Looks like a COMBOOT image but too large
 comboot_too_large:
-               call close_file
+               pm_call pm_close_file
                mov si,err_comlarge
                call writestr
                jmp enter_command
@@ -126,7 +126,7 @@ is_comboot_image:
                mov bx,100h             ; Load at <seg>:0100h
                mov cx,10000h >> SECTOR_SHIFT
                                        ; Absolute maximum # of sectors
-               call getfssec
+               pm_call getfssec
                cmp ecx,65536-256-2     ; Maximum size
                ja comboot_too_large
 
@@ -139,14 +139,6 @@ is_comboot_image:
 
                jmp comboot_seg:100h    ; Run it
 
-; Proper return vector
-; Note: this gets invoked both via INT 21h and directly via INT 20h.
-; We don't need to cld explicitly here, because comboot_exit does that
-; when invoking RESET_STACK_AND_SEGS.
-comboot_return:        cli                     ; Don't trust anyone
-               push enter_command      ; Normal return to command prompt
-               jmp comboot_exit
-
 ;
 ; Set up the COMBOOT API interrupt vectors.  This is now done at
 ; initialization time.
@@ -179,7 +171,8 @@ comboot_setup_api:
                ret
 
 ;
-; Restore the original state of the COMBOOT API vectors
+; Restore the original state of the COMBOOT API vectors, and free
+; any low memory allocated by the comboot module.
 ;
 comboot_cleanup_api:
                pusha
@@ -234,7 +227,7 @@ comboot_vectors:
                section .text16
 
 ; INT 21h: generic DOS system call
-comboot_int21: cli
+comboot_int21: sti
                push ds
                push es
                push fs
@@ -277,8 +270,7 @@ comboot_bad_int21:
 
 ; Attempted to execute invalid DOS system call
 ; The interrupt number is on the stack.
-comboot_bogus: cli                     ; Don't trust anyone
-               pop dx                  ; Interrupt number
+comboot_bogus: pop dx                  ; Interrupt number
                pop edi                 ; CS:IP
                mov cx,err_notdos
                push comboot_bogus_tail
@@ -297,19 +289,30 @@ comboot_bogus_tail:
                call crlf
                jmp enter_command
 
+; Proper return vector
+; Note: this gets invoked both via INT 21h and directly via INT 20h.
+; We don't need to cld explicitly here, because comboot_exit does that
+; when invoking RESET_STACK_AND_SEGS.
+comboot_return:
+               cli                     ; May not have a safe stack
+               push enter_command      ; Normal return to command prompt
+               ; jmp comboot_exit
+
 ;
 ; Generic COMBOOT return to command line code
 ;  stack -> where to go next
 ;     CX -> message (for _msg version)
 ;
+               extern comboot_cleanup_lowmem
 comboot_exit:
                xor cx,cx
 comboot_exit_msg:
                pop bx                  ; Return address
-               RESET_STACK_AND_SEGS SI ; Contains cld
+               RESET_STACK_AND_SEGS si ; Contains sti, cld
+               pm_call comboot_cleanup_lowmem
                call adjust_screen      ; The COMBOOT program might have changed the screen
                jcxz .nomsg
-               mov si,KernelCName
+               mov si,KernelName
                call writestr
                mov si,cx
                call writestr
@@ -392,7 +395,7 @@ comboot_getchar:
 ; INT 28h - DOS idle
 ;
 comboot_int28:
-               cli
+               sti
                cld
                call do_idle
                iret
@@ -401,7 +404,7 @@ comboot_int28:
 ; INT 29h - DOS fast write character
 ;
 comboot_int29:
-               cli
+               sti
                cld
                call writechr                   ; Preserves registers!
                iret
@@ -411,7 +414,7 @@ comboot_int29:
 ;           System call number in ax
 ;
 comboot_int22:
-               cli
+               sti
                push ds
                push es
                push fs
@@ -514,18 +517,7 @@ comapi_textmode:
 ; INT 22h AX=0006h     Open file
 ;
 comapi_open:
-               push ds
-               mov ds,P_ES
-               mov si,P_SI
-               mov di,InitRD
-               call mangle_name
-               pop ds
-               call searchdir
-               jz comapi_err
-               mov P_EAX,eax
-               mov P_CX,SECTOR_SIZE
-               mov P_SI,si
-               clc
+               pm_call pm_open_file
                ret
 
 ;
@@ -536,7 +528,7 @@ comapi_read:
                mov bx,P_BX
                mov si,P_SI
                mov cx,P_CX
-               call getfssec
+               pm_call getfssec
                jnc .noteof
                xor si,si               ; SI <- 0 on EOF, CF <- 0
 .noteof:       mov P_SI,si
@@ -548,7 +540,7 @@ comapi_read:
 ;
 comapi_close:
                mov si,P_SI
-               call close_file
+               pm_call pm_close_file
                clc
                ret
 
@@ -584,6 +576,8 @@ comapi_derinfo:
                mov P_SI,ax
                mov ax,[InitStack+2]
                mov P_FS,ax
+               mov eax,[MyIP]
+               mov P_ECX,eax
 %else
                ; Physical medium...
 
@@ -636,7 +630,7 @@ comapi_cleanup:
                test dl,3
                setnz [KeepPXE]
                sub bp,sp               ; unload_pxe may move the stack around
-               call unload_pxe
+               pm_call unload_pxe
                add bp,sp               ; restore frame pointer...
 %elif IS_SYSLINUX || IS_EXTLINUX
                ; Restore original FDC table
@@ -687,10 +681,11 @@ comapi_ipappend:
 ; INT 22h AX=0010h     Resolve hostname
 ;
 %if IS_PXELINUX
+                extern pxe_dns_resolv
 comapi_dnsresolv:
                mov ds,P_ES
                mov si,P_BX
-               call dns_resolv
+               pm_call pxe_dns_resolv
                mov P_EAX,eax
                clc
                ret
@@ -745,30 +740,31 @@ comapi_runkernel:
                cmp al,VK_TYPES-1
                ja .error
                mov [KernelType],al
+
+               ; It's not just possible, but quite likely, that ES:BX
+               ; points into real_mode_seg or xfer_buf_seg, so we
+               ; need to exercise some special care here... use
+               ; vk_append for temporary storage.
+               push ds
+               mov ds,P_ES
+               mov si,P_BX
+               mov di,vk_append
+               call strcpy
+               pop ds
+
                push ds
                mov ds,P_DS
                mov si,P_SI
                mov di,KernelName
-               call mangle_name
+               pm_call pm_mangle_name
                pop ds
-               call searchdir
+               pm_call pm_searchdir
                jz comapi_err
 
                ; The kernel image was found, so we can load it...
                mov [Kernel_SI],si
                mov [Kernel_EAX],eax
 
-               ; It's not just possible, but quite likely, that ES:BX
-               ; points into real_mode_seg or xfer_buf_seg, so we
-               ; need to exercise some special care here... use
-               ; trackbuf as an intermediary
-               push ds
-               mov ds,P_ES
-               mov si,P_BX
-               mov di,trackbuf
-               call strcpy
-               pop ds
-
 %if IS_PXELINUX
                mov al,P_CL
                mov [IPAppend],al
@@ -781,10 +777,10 @@ comapi_runkernel:
                push es
                mov dx,real_mode_seg
                mov es,dx
-               mov si,trackbuf
+               mov si,vk_append
                mov di,cmd_line_here
                call strcpy
-               mov byte [es:di-1],' '          ; Simulate APPEND
+               mov word [es:di-1],' '  ; Simulate APPEND: space plus null
                pop es
                mov [CmdLinePtr],di
                mov word [CmdOptPtr],zero_string
@@ -897,67 +893,11 @@ comapi_getcwd:
                ret
 
 ;
-; INT 22h AX=0020h     Open directory
-;
-%if IS_SYSLINUX
-comapi_opendir:
-               push ds
-               mov ds,P_ES
-               mov si,P_SI
-               mov di,InitRD
-               call mangle_name
-               pop ds
-               call searchdir
-               jnz comapi_err  ; Didn't find a directory
-               cmp eax,0
-               jz comapi_err   ; Found nothing
-                       ;ZF is unset
-               call alloc_fill_dir
-               mov P_EAX,eax
-               mov P_CX,SECTOR_SIZE
-               mov P_SI,si
-               clc
-               ret
-%else
-comapi_opendir equ comapi_err
-%endif
-
-;
-; INT 22h AX=0021h     Read directory
-;
-%if IS_SYSLINUX
-comapi_readdir:
-               mov es,P_ES
-               mov di,P_DI
-               mov si,P_SI
-               call readdir
-               mov P_EAX,eax
-               mov P_DL,dl
-               mov P_EBX,ebx
-               mov P_SI,si
-               ret
-%else
-comapi_readdir equ comapi_err
-%endif
-
-;
-; INT 22h AX=0022h     Close directory
-;
-%if IS_SYSLINUX
-comapi_closedir:
-               mov si,P_SI
-               call close_dir
-               clc
-               ret
-%else
-comapi_closedir        equ comapi_err
-%endif
-
-;
 ; INT 22h AX=0023h     Query shuffler size
 ;
 comapi_shufsize:
-               mov P_CX,bcopyxx_safe
+               ; +15 is padding to guarantee alignment
+               mov P_CX,__bcopyxx_len + 15
                ret
 
 ;
@@ -1024,9 +964,9 @@ int22_table:
                dw comapi_writeadv      ; 001D write ADV to disk
                dw comapi_kbdtable      ; 001E keyboard remapping table
                dw comapi_getcwd        ; 001F get current working directory
-               dw comapi_opendir       ; 0020 open directory
-               dw comapi_readdir       ; 0021 read directory
-               dw comapi_closedir      ; 0022 close directory
+               dw comapi_err           ; 0020 open directory
+               dw comapi_err           ; 0021 read directory
+               dw comapi_err           ; 0022 close directory
                dw comapi_shufsize      ; 0023 query shuffler size
                dw comapi_shufraw       ; 0024 cleanup, shuffle and boot raw
 int22_count    equ ($-int22_table)/2
@@ -1052,5 +992,10 @@ err_comlarge      db 'COMBOOT image too large.', CR, LF, 0
                section .bss16
                alignb 4
 DOSErrTramp    resd    33              ; Error trampolines
+
+               global ConfigName
 ConfigName     resb    FILENAME_MAX
+%ifndef HAVE_CURRENTDIRNAME
+               global CurrentDirName
 CurrentDirName resb    FILENAME_MAX
+%endif