home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / KERNELS / LODLIN15.ZIP / LOADLIN / LOADLINI.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-09-05  |  47.2 KB  |  1,587 lines

  1. ;   >>> this is file LOADLINI.ASM
  2. ;============================================================================
  3. ;   LOADLIN v1.5 (C) 1994 Hans Lermen (lermen@elserv.ffm.fgan.de)
  4. ;
  5. ;   This program is free software; you can redistribute it and/or modify
  6. ;   it under the terms of the GNU General Public License as published by
  7. ;   the Free Software Foundation; either version 2 of the License, or
  8. ;   (at your option) any later version.
  9. ;
  10. ;   This program is distributed in the hope that it will be useful,
  11. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;   GNU General Public License for more details.
  14. ;
  15. ;   You should have received a copy of the GNU General Public License
  16. ;   along with this program; if not, write to the Free Software
  17. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ;
  19. ;----------------------------------------------------------------------------
  20. ;   Comments and bug reports are welcome and may be sent to:
  21. ;   E-Mail:    lermen@elserv.ffm.fgan.de
  22. ;   SnailMail: Hans Lermen
  23. ;              Am Muehlenweg 38
  24. ;              D53424 REMAGEN-Unkelbach
  25. ;              GERMANY
  26. ;
  27. ;============================================================================
  28.  
  29.  
  30. parscommandline proc near
  31.         call    clear_to_default
  32.         mov     cx,word ptr comline-1
  33.         xchg    ch,cl
  34.         jcxz    @@ex_carry
  35.         mov     si,cx
  36.         mov     comline[si+1],0
  37.         mov     image_name,0
  38.         mov     command_line,0
  39.         mov     cl_pointer,offset command_line
  40.         lea     si,comline+1
  41.         lea     di,image_name
  42.         cld
  43.         call    get_token   ; get the zImage-file name
  44.         jz      @@ex_carry
  45.                             ; got zImage-name
  46.                             ; try to get params
  47.         cmp     image_name,'@'
  48.         jne     @@1
  49.         call    read_comline_from_file
  50.         jmp     parscommandline
  51. @@1:
  52.         lea     di,image_name
  53.         call    tolower
  54.         jmp     @@next_token
  55.  
  56. @@token_table label byte
  57.               db    'ramdisk',0
  58.               db    'vga',0
  59.               db    'mem',0
  60.               db    'root',0
  61.               db    'ro',0
  62.               db    'rw',0
  63.               db    'no387',0
  64.               db    'single',0
  65.               db    'auto',0
  66.               db    '-v',0
  67.               db    '-t',0
  68.               db    '-d',0
  69.               db    '-rb',0
  70.               db    '-rx',0
  71.               db    '-ja',0
  72.               db    '-clone',0
  73.               db    '-oldxd',0
  74.               db    'debug',0
  75.               db    'no-hlt',0
  76.               db    'reserve',0
  77.               db    'hd',0
  78.               db    'bmouse',0
  79.               db    'max_scsi_luns',0
  80.               db    'xd',0
  81.               db    '-n',0
  82.               db    0
  83.  
  84.  
  85. @@jmp_table   dw  @@ramdisk
  86.               dw  @@vga
  87.               dw  @@tolower  ; mem
  88.               dw  @@root
  89.               dw  @@ro
  90.               dw  @@rw
  91.               dw  @@tolower  ; no387
  92.               dw  @@tolower  ; single
  93.               dw  @@tolower  ; auto
  94.               dw  @@option_v
  95.               dw  @@option_t
  96.               dw  @@option_d
  97.               dw  @@option_realbios
  98.               dw  @@option_rx
  99.               dw  @@option_ja
  100.               dw  @@option_clone
  101.               dw  @@option_oldxd
  102.               dw  @@tolower  ; debug
  103.               dw  @@tolower  ; no-hlt
  104.               dw  @@tolower  ; reserve=
  105.               dw  @@tolower  ; hd=
  106.               dw  @@tolower  ; bmouse=
  107.               dw  @@tolower  ; max_scsi_luns=
  108.               dw  @@tolower  ; xd=
  109.               dw  @@option_n
  110.  
  111. @@next_token:
  112.         lea     di,aux_token
  113.         call    get_token
  114.         jz      @@ex0
  115.         lea     di,aux_token
  116.         lea     bx,@@token_table
  117.         call    check_token
  118.         js      @@not_my_token
  119.         jmp     @@jmp_table[bx]
  120.  
  121. @@ramdisk:      ; have ramdisk param
  122.         mov     got_ram_disk,1
  123.         mov     new_ram_disk,1440
  124.         jz      @@next_token
  125.         xchg    si,di
  126.         call    value_of
  127.         cmp     word ptr [si],'on' ; disable diskchange prompt ?
  128.         jne     @@ramdisk_1
  129.         mov     option_nodiskprompt,1
  130. @@ramdisk_1:
  131.         xchg    si,di
  132.         mov     new_ram_disk,ax
  133.         jmp     @@next_token
  134.  
  135. @@token_table_vga label byte
  136.               db    'normal',0
  137.               db    'extended',0
  138.               db    'ask',0
  139.               db    0
  140.  
  141. @@vga:          ; have vga - param
  142.         mov     got_vga_mode,1
  143.         mov     new_vga_mode,-1  ; default = NORMAL
  144.         jz      @@next_token
  145.         mov     bx,di
  146.         cmp     byte ptr [bx],'-'
  147.         jne     @@vga_1
  148.         inc     bx
  149. @@vga_1:
  150.         cmp     byte ptr [bx],'0'
  151.         jb      @@check_vga_sym
  152.         cmp     byte ptr [bx],'9'
  153.         jna     @@check_vga_num
  154. @@check_vga_sym:
  155.         ; DI already pointing to value
  156.         lea     bx,@@token_table_vga
  157.         call    check_token
  158.         js      @@next_token
  159.         shr     bx,1
  160.         not     bx
  161.         mov     new_vga_mode,bx
  162.         jmp     @@next_token
  163. @@check_vga_num:
  164.         xchg    si,di
  165.         call    value_of
  166.         xchg    si,di
  167.         mov     new_vga_mode,ax
  168.         jmp     @@next_token
  169.  
  170. @@ro:           ; mount root readonly
  171.         mov     got_ro_flag,1
  172.         mov     new_ro_flag,1
  173.         jmp     @@next_token
  174. @@rw:           ; mount root readwrite
  175.         mov     got_ro_flag,1
  176.         mov     new_ro_flag,0
  177.         jmp     @@next_token
  178.  
  179. @@option_t:
  180.         mov     option_t,1     ; forces also option -v
  181. @@option_v:
  182.         mov     option_v,1
  183.         jmp     @@next_token
  184.  
  185. @@option_d:
  186.         lea     di,aux_token   ; get output file name
  187.         call    get_token
  188.         jz      @@option_t     ; no file name
  189.         push_   bx,cx,dx
  190.         xor     cx,cx
  191.         lea     dx,aux_token
  192.         DosCall DOS_CREATE_FILE
  193.         pop_    bx,cx,dx
  194.         jc      @@option_t
  195.         mov     debug_file_handle,ax
  196.         jmp     @@option_t
  197.  
  198. @@option_realbios:
  199.         mov     option_realbios,1
  200.         jmp     @@next_token
  201. @@option_rx:
  202.         mov     option_rx,1
  203.         jmp     @@next_token
  204. @@option_ja:
  205.         mov     option_ja,1
  206.         jmp     @@next_token
  207. @@option_clone:
  208.         mov     option_clone,1
  209.         jmp     @@next_token
  210. @@option_oldxd:
  211.         mov     byte ptr @@num_table_root_xd+1,0ch
  212.         mov     byte ptr @@num_table_root_xd+2+1,0ch
  213.         mov     option_oldxd,1
  214.         jmp     @@next_token
  215. @@option_n:
  216.         mov     option_n,1
  217.         jmp     @@next_token
  218.  
  219.  
  220. @@token_table_root label byte
  221.         db      'fd',0
  222.         db      'hda',0,'hdb',0
  223.         db      'sda',0,'sdb',0,'sdc',0,'sdd',0,'sde',0
  224.         db      'xda',0,'xdb',0
  225.         db      0
  226. @@num_table_root label word
  227.         dw      0200h
  228.         dw      0300h,0340h
  229.         dw      0800h,0810h,0820h,0830h,0840h
  230. @@num_table_root_xd:
  231.         dw      0D00h,0D40h
  232.  
  233. @@root:
  234.         jz      @@not_my_token
  235.         push    di
  236.         lea     di,aux_token
  237.         call    tolower
  238.         pop     di
  239.         cmp     dword ptr [di],'ved/'
  240.         je      @@root_d
  241.         cmp     word ptr [di],'x0'
  242.         je      @@root_1
  243.         sub     di,2          ; force hex decoding
  244.         mov     word ptr [di],'x0'
  245. @@root_1:
  246.         xchg    si,di
  247.         call    value_of
  248.         xchg    si,di
  249.         mov     got_root_dev,1
  250.         mov     new_root_dev,ax
  251.         jmp     @@root_next_token
  252. @@root_d:
  253.         add     di,5
  254.         push    di
  255.         push    dword ptr [di]
  256.         mov     di,sp
  257.         mov     byte ptr [esp+3],0
  258.         cmp     word ptr [esp],'df'
  259.         jne     @@root_d_1
  260.         mov     byte ptr [esp+2],0
  261. @@root_d_1:
  262.         lea     bx,@@token_table_root
  263.         call    check_token
  264.         lea     esp,[esp+4]
  265.         pop     di
  266.         js      @@not_my_token
  267.         mov     ax,@@num_table_root[bx]
  268.         mov     got_root_dev,1
  269.         mov     new_root_dev,ax
  270.         or      bx,bx      ; is it the floppy
  271.         jne     @@root_d_h ; no
  272.         cmp     byte ptr [di+2],'1'
  273.         jne     @@root_next_token
  274.         inc     new_root_dev
  275.         jmp     @@root_next_token
  276. @@root_d_h:
  277.         add     di,3
  278.         cmp     byte ptr [di],0
  279.         je      @@root_next_token
  280.         cmp     byte ptr [di],'0'
  281.         jne     @@root_d_h_1
  282.         cmp     byte ptr [di+1],'x'
  283.         je      @@root_d_h_2
  284. @@root_d_h_0:
  285.         dec     di
  286.         mov     word ptr [di],'x0'
  287. @@root_d_h_2:
  288.         xchg    si,di
  289.         call    value_of
  290.         xchg    si,di
  291.         add     new_root_dev,ax
  292.         jmp     @@root_next_token
  293. @@root_d_h_1:
  294.         jb      @@not_my_token
  295.         cmp     byte ptr [di],'a'
  296.         jb      @@root_d_h_2
  297.         cmp     byte ptr [di],'f'
  298.         ja      @@not_my_token
  299.         dec     di
  300.         jmp     @@root_d_h_0
  301.  
  302. @@root_next_token:
  303.         cmp     option_n,0
  304.         jnz     @@not_my_token
  305.         jmp     @@next_token
  306.  
  307.  
  308. @@not_my_token:
  309.         push    si
  310.         lea     si,aux_token
  311.         call    @@append_to_commandline
  312.         pop     si
  313.         jmp     @@next_token
  314. @@tolower:
  315.         lea     di,aux_token
  316.         call    tolower
  317.         jmp     @@not_my_token
  318.  
  319.  
  320.  
  321. @@ex0:
  322.         lea     si,@@boot_tx
  323.         call    @@append_to_commandline
  324.         dec     cl_pointer
  325.         lea     si,image_name
  326.         cld
  327.         mov     di,si
  328. @@ex1:
  329.         lodsb
  330.         test    al,al
  331.         jz      @@ex3
  332.         cmp     al,':'
  333.         je      @@ex2
  334.         cmp     al,'\'
  335.         je      @@ex2
  336.         cmp     al,'/'
  337.         jne     @@ex1
  338. @@ex2:
  339.         mov     di,si
  340.         jmp     @@ex1
  341. @@ex3:
  342.         mov     si,di
  343.         call    @@append_to_commandline
  344. @@ex:
  345.         clc
  346.         ret
  347. @@ex_carry:
  348.         stc
  349.         ret
  350.  
  351. @@append_to_commandline:
  352.         mov     di,cl_pointer
  353. @@append_to_1:
  354.         lodsb
  355.         stosb
  356.         test    al,al
  357.         jnz     @@append_to_1
  358.         mov     byte ptr [di-1],' '
  359.         mov     byte ptr [di],al
  360.         mov     cl_pointer,di
  361.         ret
  362.  
  363. @@boot_tx     db    'BOOT_IMAGE=',0
  364.  
  365. parscommandline endp
  366.  
  367.  
  368. handle_kernel_specifics proc near
  369.         cmp     kernelversion,0
  370.         jz      @@ex
  371.         cmp     option_oldxd,0
  372.         jne     @@ex
  373.         cmp     word ptr kernelversion+2,0101h ; 1.1.x () #x
  374.         jnb     @@ex
  375.         cmp     got_root_dev,0
  376.         jz      @@ex
  377.         cmp     byte ptr new_root_dev+1,0dh
  378.         jne     @@ex
  379.         mov     byte ptr new_root_dev+1,0ch
  380. @@ex:
  381.         ret
  382. handle_kernel_specifics endp
  383.  
  384. get_token proc near
  385.         push    di
  386. @@skip_loop:
  387.         lodsb
  388.         cmp     al,' '
  389.         je      @@skip_loop
  390.         jmp     @@ok
  391. @@loop:
  392.         lodsb
  393.         cmp     al,' '
  394.         jne     @@ok
  395.         xor     al,al
  396. @@ok:
  397.         stosb
  398.         test    al,al
  399.         jne     @@loop
  400.         dec     si
  401.         pop     di
  402.         test    byte ptr es:[di],255
  403.         ret
  404. get_token endp
  405.  
  406.  
  407. readstring proc near
  408.         push    dx
  409.         mov     comline-1,255-2
  410.         lea     dx,comline-1
  411.         DosCall DOS_BUFFERED_INPUT
  412.         lea     dx,newline_tx
  413.         call    print
  414.         push    bx
  415.         movzx   bx,comline
  416.         mov     comline[bx+1],0
  417.         mov     comline-1,0
  418.         pop     bx
  419.         pop     dx
  420.         ret
  421. readstring endp
  422.  
  423.  
  424. tolower proc near
  425. ; input:
  426. ;   DS:DI= address to ASCIIZ-string
  427.         cld
  428.         xchg    si,di
  429. @@loop:
  430.         lodsb
  431.         or      al,al
  432.         jz      @@ex
  433.         cmp     al,'A'        ; tolower !
  434.         jb      @@loop
  435.         cmp     al,'Z'
  436.         ja      @@loop
  437.         add     byte ptr [si-1],'a'-'A'
  438.         jmp     @@loop
  439. @@ex:
  440.         xchg    si,di
  441.         ret
  442. tolower endp
  443.  
  444. name_compare proc near
  445. ; input:
  446. ;   DS:DI= address to ASCIIZ-string  (name1)
  447. ;          (a "=" marks end of string also)
  448. ;   CS:BX= address to ASCIIZ-string  (name2)
  449. ;   CX=    max number of character to compare
  450. ;   compare is done by ignoring upper/lower-case
  451. ; Output:
  452. ;   AX=    0 if not equal else equal
  453. ;   DI=    as changed by lodsb, pointing behind terminator (0 or '=')
  454. ;   all other register preserved
  455.           cld
  456.           push    bx
  457.           xchg    si,di
  458.           sub     bx,si
  459. @@m3:
  460.           lodsb
  461.           cmp     al,'='        ; may be name in environement
  462.           jne     short @@32
  463.           xor     al,al
  464.           jmp     short @@m35
  465. @@32:
  466.           cmp     al,'A'        ; tolower !
  467.           jb      short @@m35
  468.           cmp     al,'Z'
  469.           ja      short @@m35
  470.           add     al,'a'-'A'
  471. @@m35:
  472.           mov     ah,al
  473.           mov     al,byte ptr cs:[si+bx-1]
  474.           cmp     al,'A'        ; tolower !
  475.           jb      short @@m36
  476.           cmp     al,'Z'
  477.           ja      short @@m36
  478.           add     al,'a'-'A'
  479. @@m36:
  480.           or      al,al
  481.           jz      short @@ex_
  482.           or      ah,ah
  483.           jz      short @@exfalse
  484.           cmp     ah,al
  485.           jne     @@exfalse
  486.           loop    @@m3
  487. @@extrue:
  488.           mov     ax,1
  489. @@ex:
  490.           xchg    si,di
  491.           pop     bx
  492.           or      ax,ax
  493.           ret
  494. @@ex_:
  495.           or      ax,ax
  496.           jz      @@extrue
  497. @@exfalse:
  498.           xor     ax,ax         ;  not equal
  499.           jmp     @@ex
  500. name_compare endp
  501.  
  502.  
  503. get_env_variable proc near
  504. ; Input
  505. ;    CS:BX= Pointer to string (ASCIIZ) of desired env-variable
  506. ; Output:
  507. ;    ES:DI=    pointer to string (ASCIIZ) of variable contents (without "=")
  508. ;            or ZERO-string if not found
  509. ;    All other registers preserved
  510.           push    ds
  511.           push    ax
  512.           push    si
  513.           mov     ds,PSP_frame
  514.           mov     ds,ds:PSP_envir_frame
  515.           xor     si,si
  516.  
  517.           mov     al,byte ptr [si]
  518. @@m1:
  519.           mov     cx,80
  520.           or      al,al
  521.           mov     di,si
  522.           jz      @@ex
  523.           call    name_compare
  524.           jnz     @@found    ; string is equal, found the variable
  525.           cld
  526. @@m2:                   ; skip to next string
  527.           lodsb
  528.           or      al,al
  529.           jnz     @@m2
  530.           mov     al,byte ptr [si]
  531.           jmp     @@m1
  532. @@found:
  533. @@ex:
  534.           push    ds
  535.           pop     es
  536.           pop     si
  537.           pop     ax
  538.           pop     ds
  539.           ret
  540. get_env_variable endp
  541.  
  542.  
  543.  
  544.  
  545. value_of proc near
  546.   ; Input:
  547.   ;   DS:SI= pointer to string (ASCIIZ), which contains number to be converted
  548.   ;          (i.e.: 1234, 0xa00, ... ), all non-digit-characters (0..9,a..f,A..F)
  549.   ;          are "delimiters" and mark the end of the string
  550.   ; Output:
  551.   ;   EAX= converted number
  552.   ;   SI= pointing at the first byte behind the delimiter
  553.           cmp    byte ptr [si],'-'
  554.           pushf
  555.           jnz    @@m0
  556.           inc    si
  557.   @@m0:
  558.           push_  ebx,ecx,edx,edi,esi
  559.           mov    ebx,10
  560.           xor    edx,edx
  561.           xor    edi,edi
  562.           inc    edi
  563.           cld
  564.           lodsb
  565.           call   @@check_white
  566.           jc     @@ex
  567.           jne    @@m1
  568.           lodsb
  569.           or     al,20h   ; convert to lowercase
  570.           cmp    al,'x'
  571.           jne    @@m1
  572.           mov    ebx,16
  573.           lodsb
  574. @@m1:
  575.           call   @@check_white
  576.           jb     @@ex
  577.           xor    ecx,ecx
  578. @@m2:
  579.           inc    ecx
  580.           lodsb
  581.           call   @@check_white
  582.           jnc    @@m2
  583.           std
  584.           mov    [esp],esi ;advance pointer
  585.           dec    si
  586.           dec    si
  587. @@m3:
  588.           lodsb
  589.           or     al,20h    ; convert to lowercase
  590.           cmp    al,'9'
  591.           jna    short @@m4
  592.           add    al,9
  593. @@m4:
  594.           and    al,0fh
  595.           movzx  eax,al
  596.           imul   eax,edi
  597.           imul   edi,ebx
  598.           add    edx,eax
  599.           loop   @@m3
  600. @@ex:
  601.           mov    eax,edx
  602.           pop_   ebx,ecx,edx,edi,esi
  603.           popf
  604.           jnz    @@ex_
  605.           neg    eax
  606. @@ex_:
  607.           ret
  608.  
  609. @@check_white:
  610.           mov    ah,'f'
  611.           cmp    bl,16
  612.           je     short @@7
  613.           mov    ah,'9'
  614. @@7:
  615.           or     al,20h
  616.           cmp    al,'0'
  617.           jb     short @@9
  618.           cmp    al,ah
  619.           ja     short @@9
  620.           cmp    al,'9'
  621.           jbe    short @@8
  622.           cmp    al,'a'
  623.           jae    short @@8
  624. @@9:
  625.           mov    al,' '
  626. @@8:
  627.           cmp    al,'0'
  628.           ret
  629.  
  630. value_of endp
  631.  
  632.  
  633. check_VCPI_present proc near
  634.           pushad
  635.           push    es
  636.           push    ds
  637.           lea     esp,[esp-4] ; local space
  638. @@stack struc
  639.   @@handle dw   ?
  640.            dw   ?
  641.   @@ds     dw   ?
  642.   @@es     dw   ?
  643.   pushad_struc @@
  644. @@stack ends
  645.           xor     eax,eax      ; check EMM_interrupt present
  646.           mov     [esp].@@eax,eax
  647.           mov     es,ax
  648.           mov     es,word ptr es:[emm_int*4+2]
  649.           cmp     Dword ptr es:[10+4],'0XXX'
  650.           jne     @@ex
  651.           cmp     dword ptr es:[10],'XMME'
  652.           je      @@ok
  653.           cmp     dword ptr es:[10],'QMME' ; this also works (as told by <J.S.Peatfield@damtp.cambridge.ac.uk>)
  654.           jne     @@ex
  655. @@ok:
  656.           mov     ax,4000h   ; check emm menager status
  657.           int     emm_int
  658.           or      ah,ah
  659.           jnz     @@ex
  660.           mov     ax,_GET_VERSION*256   ; get version
  661.           int     emm_int
  662.           cmp     ax,40h     ; version must be greater 4.0
  663.           jb      @@ex
  664.  
  665.           mov     ax,_ALLOCATE_RAW_PAGES
  666.           mov     bx,4
  667.           int     emm_int
  668.           cmp     ah,0
  669.           jnz     @@ex
  670.           mov     word ptr [esp].@@handle,dx     ; save handle
  671.           mov     ax,0DE00h   ; check for VCPI present
  672.           int     emm_int
  673.           cmp     ah,0
  674.           jne     short @@notok
  675.           mov     byte ptr [esp].@@eax,1
  676. @@notok:
  677.           mov     dx,word ptr [esp].@@handle
  678.           mov     ax,_DEALLOCATE_PAGES*256
  679.           int     emm_int
  680. @@ex:
  681.           lea     esp,[esp+4] ; discar local space
  682.           pop     ds
  683.           pop     es
  684.           popad
  685.           or      ax,ax
  686.           ret
  687. check_VCPI_present endp
  688.  
  689. get_VCPI_interface proc near
  690.           push    cs                  ;* buffer for server GDT entries
  691.           push    offset gdtvcpi_code ;*
  692.           push    cs                  ;* buffer for server page0
  693.           push    offset page0        ;*
  694.           call    get_protected_mode_interface
  695.           ret
  696. get_VCPI_interface endp
  697.  
  698.  
  699. check_low_mem_mapping proc near
  700.           call    get_VCPI_interface
  701.           xor     edx,edx
  702.           lea     si,page0
  703.           cld
  704.           mov     cx,(640/4)
  705. @@loop:
  706.           lodsd
  707.           and     ax,0f000h
  708.           cmp     eax,edx
  709.           jne     @@ex_false
  710.           add     edx,1000h
  711.           loop    @@loop
  712.           mov     ax,1
  713. @@ex:
  714.           or      ax,ax
  715.           ret
  716. @@ex_false:
  717.           xor     ax,ax
  718.           jmp     @@ex
  719. check_low_mem_mapping endp
  720.  
  721.  
  722. get_protected_mode_interface proc near
  723.           ARG     server_pagebuffer:dword,server_selectors:dword = returnpop
  724.           push    bp
  725.           mov     bp,sp
  726.           push    si
  727.           push    di
  728.           push    ds
  729.           push    es
  730.  
  731.                                     ; convert pagebuffer to linear address
  732.           movzx   eax,word ptr server_pagebuffer+2
  733.           movzx   ebx,word ptr server_pagebuffer
  734.           shl     eax,4
  735.           add     eax,ebx
  736.           shr     eax,4      ; make real mode address
  737.  
  738.           ;XXXXXXXXXX
  739.           push    ds
  740.           mov     es,ax                ; ES = frame of server_pagebuf
  741.           xor     di,di                ; ES:DI = >buffer for page0-table<
  742.           lds     si,server_selectors ; DS:DI = >3 GDT entries for VCPI
  743.                                ; calling VCPI server
  744.           mov     ax,0DE01h
  745.           int     emm_int
  746.           pop     ds
  747.  
  748. IF 0   ; do not need this here
  749.                                       ; save VCPI server entry for protected mode
  750.           mov     dword ptr server_vcpi_entry,ebx
  751.                                       ; set the VCPI-Code selector
  752.           mov     word ptr server_vcpi_entry+4,g_vcpi_code
  753. ENDIF
  754.           ;XXXXXXXXXXX
  755.  
  756.  
  757.  
  758.           pop     es
  759.           pop     ds
  760.           pop     di
  761.           pop     si
  762.           pop     bp
  763.           ret     returnpop
  764. get_protected_mode_interface endp
  765.  
  766.  
  767. try_biosintv proc near
  768.           pushad
  769.           mov      ax,DOS_OPEN_FILE shl 8
  770.           lea      dx,@@fname
  771.           DosInt
  772.           jc       @@ex_false
  773.           mov      bx,ax
  774.           mov      ax,4402h
  775.           mov      cx,size intv_buf
  776.           lea      dx,intv_buf
  777.           DosInt
  778.           pushf
  779.           push     ax
  780.           DosCall  DOS_CLOSE_FILE
  781.           pop      ax
  782.           popf
  783.           jc       @@ex_false
  784.           mov      intv_size,ax
  785.           mov      ax,1
  786. @@ex:
  787.           or       ax,ax
  788.           popad
  789.           ret
  790. @@ex_false:
  791.           xor     ax,ax
  792.           jmp     @@ex
  793. @@fname   db     '$BIOSINT',0
  794. try_biosintv endp
  795.  
  796. try_realbios proc near
  797.           pushad
  798.           mov      ax,DOS_OPEN_FILE shl 8
  799.           lea      dx,@@fname_realbios
  800.           DosInt
  801.           jc       @@ex_false
  802.           mov      bx,ax
  803.           lea      dx,intv_buf
  804.           mov      cx,realbios_end-intv_buf
  805.           DosCall  DOS_READ_FROM_HANDLE
  806.           pushf
  807.           push     ax
  808.           DosCall  DOS_CLOSE_FILE
  809.           pop      ax
  810.           popf
  811.           jc       @@ex_false
  812.           cmp      ax,realbios_end-intv_buf
  813.           jne      @@ex_false
  814.           mov      intv_size,ax
  815.           cmp      cs:option_rx,1
  816.           je       @@ex_true
  817.                    ; we now check the BIOS-revision to be sure
  818.                    ; that we have the right file
  819.           push     es
  820.           mov      ax,0ffffh
  821.           mov      es,ax
  822.           mov      eax,dword ptr es:[biosdate-reset_jmpop]
  823.           cmp      eax,dword ptr cs:biosdate
  824.           jne      @@ex_wrong_bios
  825.           mov      eax,dword ptr es:[(biosdate-reset_jmpop)+4]
  826.           cmp      eax,dword ptr cs:biosdate+4
  827.           jne      @@ex_wrong_bios
  828.                    ; we check the real_bios_magic
  829.           cmp      cs:real_bios_magic,0a5a5h
  830.           jne      @@ex_wrong_bios
  831. @@ex_true:
  832.           mov      ax,1
  833.           pop      es
  834. @@ex:
  835.           or       ax,ax
  836.           popad
  837.           ret
  838. @@ex_false:
  839.           mov     intv_size,0
  840.           xor     ax,ax
  841.           jmp     @@ex
  842. @@ex_wrong_bios:
  843.           pop     es
  844.           mov     wrong_realbios,1
  845.           call    force_error_verbose
  846.           jmp     @@ex_false
  847.  
  848. @@fname_realbios db REALBIOS_FILE,0
  849. try_realbios endp
  850.  
  851. get_default_bios_intvectors proc near
  852.           cmp      option_ja,0
  853.           jnz      @@first_javier
  854.           cmp      option_realbios,0
  855.           jnz      @@first_realbios
  856.           call     try_biosintv
  857.           jnz      @@ex
  858.           call     try_realbios
  859. @@ex:
  860.           ret
  861. @@first_realbios:
  862.           call     try_realbios
  863.           jnz      @@ex
  864.           call     try_biosintv
  865.           jmp      @@ex
  866. @@first_javier:
  867.           mov      intv_size,0
  868.           jmp      @@ex
  869. get_default_bios_intvectors endp
  870.  
  871.  
  872. pmode_return_esp   dd   ?  ; used to return from real-mode-switch
  873. real_IDTR          dw       03ffh    ;needed to load real intvector after switch
  874.                    dd       0
  875.  
  876. pmode_task proc near
  877. ; We come here in protected mode via VCPI-CALL
  878. ; have only to set up all things to switch back to 386-realmode
  879. ;
  880. ; We follow the INTEL recomended procedure to do this
  881. ; (80386 Programmer's Reference Manual, Chapter 14.5)
  882. ;
  883.           .386p
  884.           CLI  ; just to be sure
  885.  
  886.           ; 1. We know, that paging is enabled,
  887.           ;             that linear addresses have identical mapping
  888.           ;    so we can clear the PG bit
  889.  
  890.           mov     eax,CR0
  891.           and     eax,07fffffffh
  892.           mov     CR0,eax    ; paging is off
  893.           xor     eax,eax
  894.           mov     CR3,eax    ; clear out paging cache
  895.  
  896.           ; 2. We must transfer control to segment with 64K limit
  897.           ;    we ARE on such a segment, no need to do it here
  898.  
  899.           ; 3. Load segment registers SS,DS,ES,FS,GS with a selector
  900.           ;    that points to a descriptor containing the the values:
  901.           ;      limit 64k     =  0FFFFh
  902.           ;      byte granularity
  903.           ;      Expand up
  904.           ;      writable
  905.           ;      present
  906.           ;
  907.           ;    We have that descriptor, its our gdt_data.
  908.           mov     ax,g_data
  909.           mov     ss,ax
  910.           mov     ds,ax
  911.           mov     es,ax
  912.           mov     fs,ax
  913.           mov     gs,ax
  914.  
  915.           ; 4. Disable Interrrupts
  916.           ;    ( we did that above )
  917.           ; 5. Clear the PE bit in CR0
  918.           mov     eax,CR0
  919.           and     al,0feh
  920.           mov     CR0,eax  ; we are go back to realmode
  921.  
  922.           ; 6. Flush the instruction queue and load CS with approritate value
  923.           ;jmp     far ptr @@here
  924.           db      0EAh
  925.           dw      @@here,High_Seg
  926. @@here    label   far
  927.  
  928.           ; 7. Use LIDT instruction to load the base and limits of the
  929.           ;    real-mode interrupt vector table
  930.           lidt    fword ptr cs:real_IDTR
  931.  
  932.           .386
  933.           ; 8. Enable interrupts (we are doing this later)
  934.           ; 9. Load segment register
  935.           mov     ax,High_Seg
  936.           mov     ss,ax
  937.           mov     ds,ax
  938.           mov     es,ax
  939.           mov     fs,ax
  940.           mov     gs,ax
  941.           mov     esp,pmode_return_esp
  942.           ; now we are in "real" real-mode
  943.  
  944.           call    restore_bios_default_vectors
  945. @@ex:
  946.           popad
  947.           ret
  948. pmode_task endp
  949.  
  950. iodelay   macro
  951.             jmp short $+2
  952.             jmp short $+2
  953.           endm
  954.  
  955. get_mem_from_CMOS proc near
  956.           pushf
  957.           cli
  958.           push    bx
  959.           mov     al,18h
  960.           out     [070h],al
  961.           dec     al
  962.           mov     bl,al
  963.           iodelay
  964.           in      al,[071h]
  965.           mov     ah,al
  966.           mov     al,bl
  967.           iodelay
  968.           out     [070h],al
  969.           iodelay
  970.           in      al,[071h] ; extended mem read from CMOS
  971.           pop     bx
  972.           popf
  973.           ret
  974. get_mem_from_CMOS endp
  975.  
  976.  
  977.  
  978. restore_bios_default_vectors proc near
  979.           push_   es,ds,ax,cx,si,di
  980.           xor     di,di
  981.           mov     es,di
  982.           cmp     cs:have_to_intercept_setup,0
  983.           jz      @@p2
  984.                               ; No REALBIOS or device driver
  985.           cmp     word ptr cs:intv_buf+(4*15h+2),0
  986.           jne     @@ex        ; Only once
  987.           mov     eax,dword ptr es:[4*15h]
  988.           mov     dword ptr cs:intv_buf+(4*15h),eax
  989.           call    get_mem_from_CMOS
  990.           mov     cs:real_bios_int15,ax
  991.           jmp     @@p1
  992. @@p2:
  993.           mov     cx,cs:intv_size
  994.           shr     cx,2
  995.           jcxz    @@ex
  996.           ; we now reset the intvector to bios-defaults
  997.           push    cs
  998.           pop     ds
  999.           cmp     cx,(size intv_buf)/4  ; have we REALBIOS
  1000.           jna     @@1     ; no
  1001.                           ; yes
  1002.                           ; restoring BIOSdata also
  1003.           mov     cx,(dummy_dos_data-intv_buf)/4
  1004. @@1:
  1005.           lea     si,intv_buf
  1006.           cld
  1007.           rep movsd
  1008.           cmp     cs:intv_size,(size intv_buf)  ; have we REALBIOS
  1009.           jna     @@8      ; no
  1010.                            ; yes, restoring BIOSscratch also
  1011.           mov     di,09FC0h
  1012.           mov     es,di
  1013.           xor     di,di
  1014.           lea     si,bios_scratch
  1015.           mov     cx,(size bios_scratch)/4
  1016.           rep movsd
  1017.                            ; now reprogram the PICs (8259A)
  1018.                            ; (may be redirected by VCPI-client)
  1019.           mov     al,11h        ; enter programming mode
  1020.           out     [20h],al      ; master
  1021.           iodelay
  1022.           out     [0A0h],al     ; slave
  1023.           iodelay
  1024.           mov     al,8          ; IRQ0..7 --> INT8..F
  1025.           out     [21h],al      ; master
  1026.           iodelay
  1027.           mov     al,70h        ; IRQ8..F --> INT70..77
  1028.           out     [0A1h],al     ; slave
  1029.           iodelay
  1030.           mov     al,4          ; master bit
  1031.           out     [21h],al      ; master
  1032.           iodelay
  1033.           mov     al,2          ; slave bit
  1034.           out     [0A1h],al     ; slave
  1035.           iodelay
  1036.           mov     al,1          ; 8086 mode
  1037.           out     [21h],al      ; master
  1038.           iodelay
  1039.           out     [0A1h],al     ; slave
  1040.           iodelay
  1041.           mov     al,cs:slaveIMR
  1042.           out     [0A1h],al     ; slave
  1043.           iodelay
  1044.           mov     al,cs:masterIMR
  1045.           out     [21h],al      ; master
  1046.  
  1047. @@p1:                      ; we hook on the INT15
  1048.           xor     ax,ax
  1049.           mov     es,ax
  1050.           mov     word ptr es:[4*15h],offset our_int15
  1051.           mov     word ptr es:[4*15h+2],cs
  1052.                            ; now we must reinit the video controler
  1053.                            ; to the values just set in the BIOS-data
  1054.                            ; we do it by calling the appropriate INT 10h
  1055.           mov     ax,3003h ; al = color mode
  1056.           and     ah,byte ptr cs:bios_data+10h ; get EQUIPPEMENT-flags
  1057.           cmp     ah,30h
  1058.           jne     @@6
  1059.           mov     al,7     ; al = mono mode
  1060. @@6:
  1061.           xor     ah,ah
  1062.           INT     10h
  1063. @@8:
  1064.           push    ds
  1065.           pop     es
  1066. @@ex:
  1067.           mov     cs:intv_size,0   ; avoid second call
  1068.           pop_    es,ds,ax,cx,si,di
  1069.           ret
  1070. restore_bios_default_vectors endp
  1071.  
  1072.  
  1073. our_int15 proc near
  1074. ; interrupt 15 hook, in case of realbios
  1075.           cmp     ah,88h
  1076.           je      @@we_do_it
  1077.           jmp     dword ptr cs:intv_buf+(4*15H)
  1078. @@we_do_it:
  1079.           mov     ax,cs:real_bios_int15
  1080. ;;;test          mov     ax,0c00h*4
  1081.           iret
  1082. our_int15 endp
  1083.  
  1084.  
  1085.  
  1086. switch_to_protected_mode_and_return_in_386realmode proc near
  1087. ; NOTE: must have called "prepare_for_protected_mode" before this !
  1088. ;
  1089. ; returns with interrpts disabled
  1090. ; all registers preserved, all segment registers = "High_Seg"
  1091.           cmp    cs:have_to_force_realmode,0
  1092.           jnz    @@goon
  1093.           ret
  1094. @@goon:
  1095.           mov    cs:have_to_force_realmode,0
  1096.           pushad
  1097.           mov    pmode_return_esp,esp
  1098.           lea    ax,pmode_task
  1099.           movzx  eax,ax
  1100.           mov    dword ptr protected_mode_target,eax
  1101.           mov    word ptr protected_mode_target+4,g_code
  1102.           mov     esi,High_Seg
  1103.           shl     esi,4
  1104.           lea     si,our_CR3[si]
  1105.           CLI
  1106.           mov     ax,0DE0Ch
  1107.           int     emm_int    ; jumps to protected mode
  1108.           ; does NOT return here
  1109.           ; "pmode_task" does return directly to our caller
  1110. switch_to_protected_mode_and_return_in_386realmode endp
  1111.  
  1112.  
  1113. ; input:
  1114. ;   ES:DI   pointer to string
  1115. ;   AL       = terminating character
  1116. ; output:
  1117. ;   AX=       length of string, not counting terminating character
  1118. ;   all other registers preserved
  1119. strlen proc near
  1120.         .8086
  1121.         push_  di,cx
  1122.         xor     cx,cx
  1123.         dec     cx
  1124.         cld
  1125.         repne   scasb
  1126.         mov     ax,di
  1127.         dec     ax
  1128.         pop_    di,cx
  1129.         sub     ax,di
  1130.         .386
  1131.         ret
  1132. strlen endp
  1133.  
  1134.  
  1135. get_kernel_version proc near
  1136.   ; Input:
  1137.   ;   DS=CS
  1138.   ; Output:
  1139.   ;   EAX= converted verion number as:
  1140.   ;        1.2.3 (root:pipapo) #4 ...  --->  EAX= 01020304h
  1141.   ;        1.2.3                       --->  EAX= 01020300h
  1142.   ;   all other registers preserved
  1143.          xor      eax,eax
  1144.          cmp      have_to_intercept_setup,2
  1145.          jne      @@ex
  1146.          cmp      setup_header_version,0105h
  1147.          jb       @@ex
  1148.          cmp      kernel_version,0
  1149.          jz       @@ex
  1150.          push_    esi,edx
  1151.          mov      si,kernel_version
  1152.          lea      si,setup_prog[si]
  1153.          call     value_of
  1154.          mov      edx,eax
  1155.          call     value_of
  1156.          ror      eax,8
  1157.          shld     edx,eax,8
  1158.          call     value_of
  1159.          ror      eax,8
  1160.          shld     edx,eax,8
  1161.          xor      eax,eax
  1162.          cmp      byte ptr [si-1],0  ; end of string ?
  1163.          je       @@ex_
  1164.          cld
  1165. @@loop:
  1166.          lodsb
  1167.          test     ax,ax
  1168.          jz       @@ex_
  1169.          cmp      al,'#'
  1170.          jne      @@loop
  1171.          call     value_of
  1172.          ror      eax,8
  1173. @@ex_:
  1174.          shld     edx,eax,8
  1175.          mov      eax,edx
  1176.          pop_     esi,edx
  1177. @@ex:
  1178.          ret
  1179. get_kernel_version endp
  1180.  
  1181. writechar proc near
  1182.          push_   eax,edx
  1183.          push    eax
  1184.          mov     byte ptr [esp+1],'$'
  1185.          mov     dx,sp
  1186.          call    print
  1187.          add     sp,4
  1188.          pop_    eax,edx
  1189.          ret
  1190. writechar endp
  1191.  
  1192.  
  1193. writestring proc near
  1194.          cld
  1195. @@1:
  1196.          lodsb
  1197.          test    al,al
  1198.          jz      @@ex
  1199.          call    writechar
  1200.          loop    @@1
  1201. @@ex:
  1202.          ret
  1203. writestring endp
  1204.  
  1205. writehexdigit proc near
  1206.          push  eax
  1207.          and   al,0fh
  1208.          add   al,'0'
  1209.          cmp   al,'9'
  1210.          jna   @@m1
  1211.          add   al,'A'-('9'+1)
  1212. @@m1:
  1213.          call  writechar
  1214.          pop   eax
  1215.          ret
  1216. writehexdigit endp
  1217.  
  1218. writehexbyte proc  near
  1219.          push    eax
  1220.          ror     eax,4
  1221.          call    writehexdigit
  1222.          rol     eax,4
  1223.          call    writehexdigit
  1224.          pop     eax
  1225.          ret
  1226. writehexbyte endp
  1227.  
  1228.  
  1229. writehexword proc near
  1230.          push    eax
  1231.          ror     eax,8
  1232.          call    writehexbyte
  1233.          rol     eax,8
  1234.          call    writehexbyte
  1235.          pop     eax
  1236.          ret
  1237. writehexword endp
  1238.  
  1239.  
  1240. force_error_verbose proc near
  1241.         mov      option_v,1
  1242.         mov      option_t,1
  1243.         mov      option_t_forced,1
  1244.         ret
  1245. force_error_verbose endp
  1246.  
  1247. print_verbose proc near
  1248.          pushad
  1249.          push_  ds,es
  1250.  
  1251. @@print  macro  tx
  1252.           lea    dx,tx
  1253.           call   print
  1254.          endm
  1255. @@cr     macro
  1256.           call   print_crlf
  1257.          endm
  1258. @@prints macro  tx,count
  1259.           mov    cx,count
  1260.           lea    si,tx
  1261.           call   writestring
  1262.          endm
  1263. @@hexw   macro  v
  1264.           mov    ax,v
  1265.           call   writehexword
  1266.          endm
  1267.  
  1268.          @@print  @@t1
  1269.          @@prints image_name,<size image_name>
  1270.          cmp      have_to_intercept_setup,2
  1271.          jne      @@m1
  1272.          cmp      setup_header_version,0105h
  1273.          jb       @@m1
  1274.          cmp      kernel_version,0
  1275.          jz       @@1
  1276.          @@print  @@t1_
  1277.          mov      dx,kernel_version
  1278.          add      dx,offset setup_prog
  1279.          call     print
  1280. @@m1:
  1281.          @@print  @@t2
  1282.          @@hexw   kernel_size
  1283.          @@print  @@t2_
  1284.          @@hexw   new_setup_size
  1285.          @@print  @@t3
  1286.          @@hexw   ram_disk
  1287.          @@print  @@t4
  1288.          @@hexw   root_dev
  1289.          lea      dx,@@trw
  1290.          cmp      ro_flag,0
  1291.          jz       @@2
  1292.          lea      dx,@@tro
  1293. @@2:
  1294.          call   print
  1295.          @@print  @@v1
  1296.          @@hexw   vga_mode
  1297.          @@print  @@c1
  1298.          lea      di,command_line
  1299.          xor      ax,ax
  1300.          call     strlen
  1301.          push     ax
  1302.          call   writehexword
  1303.          @@print  @@c2
  1304.          pop      cx
  1305.          @@prints command_line,cx
  1306.          @@cr
  1307.  
  1308. @@verbose_stat:
  1309.  
  1310.          @@print  @@t21
  1311.          mov      ax,High_Seg
  1312.          sub      ax,kernel_load_frame
  1313.          call   writehexword
  1314.          @@print  @@t21_
  1315.          mov      ax,maximum_setup_sects*512
  1316.          call   writehexword
  1317.          @@print  @@t22
  1318.          mov      ah,88h
  1319.          cmp      intv_size,15h*4
  1320.          jnb      @@sim_int15
  1321.          cmp      have_to_intercept_setup,0
  1322.          jz       @@sim_int15_1
  1323.          call     get_mem_from_CMOS
  1324.          jmp      @@1
  1325.          ; we take int 15 as is, result may be wrong
  1326.          ;                       but Linux takes this as memory
  1327. @@sim_int15_1:
  1328.          int      15h
  1329.          jmp      @@1
  1330. @@sim_int15:
  1331.          cmp      wrong_realbios,0
  1332.          jne      @@sim_int15_1
  1333.          cmp      cs:real_bios_magic,0a5a5h  ; have we a saved value
  1334.          jne      @@sim_int15_2              ; no
  1335.          mov      ax,cs:real_bios_int15      ; yes
  1336.          jmp      @@1
  1337. @@sim_int15_2:
  1338.          ; we take int 15 routine as saved by BIOSINTV
  1339.          ; hopefully this gets better result
  1340.          pushf
  1341.          cli
  1342.          push     cs
  1343.          push     offset @@1
  1344.          push     dword ptr intv_buf+(15h*4)
  1345.          retf
  1346. @@1:
  1347.          shr      ax,2
  1348.          add      ax,100h
  1349.          call   writehexword
  1350.  
  1351.  
  1352.          @@print  @@t5
  1353.          lea      dx,@@real_
  1354.          cmp      cpu_type,cpu_386GE
  1355.          je       @@3
  1356.          lea      dx,@@real_p
  1357.          ja       @@3
  1358.          lea      dx,@@v86
  1359. @@3:
  1360.          call   print
  1361.          cmp      wrong_realbios,0
  1362.          je       @@3__
  1363.          @@print  @@t6_
  1364.          lea      dx,@@t6__
  1365.          jmp      @@3_1
  1366. @@3__:
  1367.          lea      dx,@@t6
  1368.          cmp      intv_size,(size intv_buf)  ; have we REALBIOS
  1369.          jna      @@3_
  1370.          lea      dx,@@t6_
  1371. @@3_:
  1372.          call   print
  1373.          lea      dx,@@no
  1374.          cmp      intv_size,0
  1375.          jz       @@3_1
  1376.          lea      dx,@@yes
  1377. @@3_1:
  1378.          call   print
  1379.          @@print  @@t7
  1380.          lea      dx,@@no
  1381.          cmp      have_to_intercept_setup,1
  1382.          jb       @@3_2
  1383.          lea      dx,@@setup_
  1384.          je       @@3_2
  1385.          lea      dx,@@setup
  1386. @@3_2:
  1387.          call   print
  1388.  
  1389.          @@print  @@s
  1390.          mov      bx,cpu_check_status
  1391.          mov      dx,@@stable[bx]
  1392.          call   print
  1393.          @@print  @@cc1
  1394.          lea      di,comline+1
  1395.          xor      ax,ax
  1396.          call     strlen
  1397.          push     ax
  1398.          call   writehexword
  1399.          @@print  @@cc2
  1400.          pop      cx
  1401.          @@prints comline+1,cx
  1402.          @@print  @@started
  1403.          lea      dx,@@rundos
  1404.          cmp      can_exit_to_dos,0
  1405.          jnz      @@4_1
  1406.          lea      dx,@@runshell
  1407. @@4_1:
  1408.          call     print
  1409.  
  1410.          cmp      cannot_load_because_of_windows,0
  1411.          jz       @@5
  1412.          @@print  @@sw
  1413. @@5:
  1414.          cmp      cpu_type,cpu_386GE_real_paging
  1415.          jne      @@6
  1416.          @@print  @@w1
  1417. @@6:
  1418.  
  1419.  
  1420.          mov      ax,High_Seg
  1421.          sub      ax,kernel_load_frame
  1422.          cmp      kernel_size,ax
  1423.          jb       @@7
  1424.          @@print  @@w2
  1425. @@7:
  1426.          cmp      new_setup_size,maximum_setup_sects*512
  1427.          jna      @@8
  1428.          @@print  @@w3
  1429. @@8:
  1430.  
  1431.          pop_   ds,es
  1432.          popad
  1433.          ret
  1434.  
  1435. @@t1     db         13,10,'Your current LINUX kernel boot configuration is:'
  1436.          db         13,10,'  image file:       $'
  1437. @@t1_    db         13,10,'  kernel version    $'
  1438. @@t2     db         13,10,'  kernel size:     0x$'
  1439. @@t2_    db               '0              setup size:  0x$'
  1440. @@t3     db         13,10,'  ram disk size:    0x$'
  1441. @@t4     db         13,10,'  root device:      0x$'
  1442. @@tro    db     '  read only$'
  1443. @@trw    db     '  read/write$'
  1444. @@v1     db         13,10,'  VGA mode:         0x$'
  1445. @@c1     db         13,10,'  command line size 0x$'
  1446. @@c2     db         13,10,'  command line:'
  1447.          db         13,10,'    $'
  1448. @@t21    db         13,10,'Your current DOS/CPU configuration is:'
  1449.          db         13,10,'  load buffer size:   0x$'
  1450. @@t21_   db               '0   setup buffer size:   0x$'
  1451. @@t22    db         13,10,'  total memory:     0x$'
  1452. @@t5     db   '000',13,10,'  CPU is in $'
  1453. @@t6     db         13,10,'  BIOSINTV.SYS:   $'
  1454. @@t6_    db         13,10,'  REALBIOS:       $'
  1455. @@t6__   db     'YES, but ROM-BIOS-DATE differs, must rerun REALBIOS.EXE$'
  1456. @@t7     db         13,10,'  SetupIntercept: $'
  1457. @@yes    db     'YES$'
  1458. @@no     db     'NO$'
  1459. @@v86    db     'V86 mode$'
  1460. @@real_  db     'REAL mode$'
  1461. @@real_p db     'undocumented REAL PAGING mode, trying any way$'
  1462. @@setup_ db     'YES, patching setup code$'
  1463. @@setup  db     'YES, legal intercept$'
  1464. @@s      db         13,10,'  stat$'
  1465. @@s8     db     '4: VCPI_present, physmap=logmap, all OK for switch to realmode$'
  1466. @@s6     db     '3: VCPI_present, but physmap != logmap (check aborted)$'
  1467. @@s4     db     '2: cpu_V86, but no VCPI available (check aborted)$'
  1468. @@s2     db     '1: cpu in real 386 mode, no need to backswitch$'
  1469. @@s0     db     '0: cpu < 386$'
  1470. @@stable dw     @@s0,@@s2,@@s4,@@s6,@@s8
  1471. @@cc1    db         13,10,'  input params size 0x$'
  1472. @@cc2    db         13,10,'  input params:'
  1473.          db         13,10,'    $'
  1474. @@started db        13,10,'  LOADLIN started from $'
  1475. @@rundos db               'DOS-prompt',13,10,'$'
  1476. @@runshell db             'CONFIG.SYS (shell= ...)',13,10,'$'
  1477. @@sw     db     '  You are running under MS-WINDOWS',13,10,'$'
  1478. @@w1     db     'WARNING:',13,10
  1479.          db     '  Your CPU is in realmode, but PAGING is enabled !',13,10
  1480.          db     '  This is possible, but neither documented nor supported by INTEL.',13,10
  1481.          db     "  May be your motherboard's BIOS is mapping shadow ram this way,",13,10
  1482.          db     '  or you are using one of those old and strange EMM managers,',13,10
  1483.          db     '  but probably this is an indication of a not exactly compatible',13,10
  1484.          db     '  486 clone. If you are not using one of the older EMM-managers',13,10
  1485.          db     '  you better should use the -clone switch to work around.',13,10,'$'
  1486. @@w2     db     'WARNING: Not enough free memory below 90000h (load buffer size)$',13,10
  1487. @@w3     db     'WARNING: The setup buffer of LOADLIN is too small (must recompile)$',13,10
  1488.  
  1489. print_verbose_stat:
  1490.          pushad
  1491.          push_  ds,es
  1492.          jmp    @@verbose_stat
  1493. print_verbose endp
  1494.  
  1495.  
  1496. close_debug_file proc near
  1497.          cmp     debug_file_handle,0
  1498.          jz      @@ex
  1499.          push_   ax,bx
  1500.          mov     bx,debug_file_handle
  1501.          DosCall DOS_CLOSE_FILE
  1502.          mov     debug_file_handle,0
  1503.          pop_    ax,bx
  1504. @@ex:
  1505.          ret
  1506. close_debug_file endp
  1507.  
  1508.  
  1509. ;=============================================================================
  1510. logo_tx               label byte
  1511. IF 0
  1512.   INCLUDE LOADLINA.ASM
  1513. ENDIF
  1514.                       db   'LOADLIN v1.5 (C) 1994 Hans Lermen (lermen@elserv.ffm.fgan.de)',13,10,'$'
  1515. comspec_tx            db   'comspec',0
  1516. windows_tx            db   'windir',0
  1517. err_uppermem_tx       db   'Not enough free memory between 90000h and 9ffffh,',13,10
  1518.                       db   'may be you have some zombie programs, try to reboot.',13,10
  1519.                       db   "If this doesn't help, try to find out what driver occupies this space."
  1520. newline_tx            db   13,10,'$'
  1521. enter_commandline_tx  db   'Please enter name of kernel image file followed by optional ',13,10
  1522.                       db   'command line parameters for Linux (e.g.  root=XXXX)',13,10
  1523.                       db   'or @file ( file = param file ) or "empty string" to abort:',13,10,'$'
  1524. abort_tx              db   'LOADLIN aborted by user',13,10,'$'
  1525. err_file_notfound_tx  db   'Image file not found,',13,10,'$'
  1526. enter_file_tx         db   'enter file name of Image:',13,10,'$'
  1527. err_wrong_file_tx     db   'not an Image file,',13,10,'$'
  1528. err_wrong_setup_tx    db   'Your current configuration needs interception of "setup.S,"',13,10
  1529.                       db   'but the setup-code in your Image file is *very* old (or wrong)',13,10
  1530.                       db   'Please use BIOSINTV/REALBIOS or try an other Image file',13,10,'$'
  1531. err_setup_too_long_tx db   'Ooops..., size of "setup.S" has become too long for LOADLIN,',13,10
  1532.                       db   'please E-mail this condition to lermen@elserv.ffm.fgan.de !',13,10,'$'
  1533. err_kernel_to_big_tx  db   'not enough memory below 90000h to load kernel',13,10,'$'
  1534. err_io_tx             db   'IO Error during load',13,10,'$'
  1535. insert_floppy_tx      db   'Insert floppy disk for loading into RAMDISK',13,10,'$'
  1536. err_cpu_v86_tx        db   13,10,'CPU is in V86-mode (may be WINDOWS, EMM386, QEMM, 386MAX, ...)',13,10
  1537.                       db   'You need pure 386/486 real mode or a VCPI server to boot Linux',13,10
  1538.                       db   'VCPI is supported by most EMS drivers (if EMS is enabled),',13,10
  1539.                       db   'but never under MS-WINDOWS (MICROSOFT doesn''t like P0 for users)',13,10
  1540.                       db   'If loading via VCPI you also MUST have:',13,10
  1541.                       db   '  1. An interceptable setup-code (Javiers method, see MANUAL.TXT)',13,10
  1542.                       db   '     or DEVICE=BIOSINTV.SYS as the very first command in CONFIG.SYS',13,10
  1543.                       db   '     or create a ',REALBIOS_FILE,' file using the REALBIOS.EXE utility.',13,10
  1544.                       db   '  2. Identical Physical-to-Virtual mapping for the first 640 Kbytes',13,10,'$'
  1545. err_wrong_cpu_tx      db   'You need a 386 CPU at minimum, but you haven''t !',13,10,'$'
  1546. err_comfile_tx        db   'error on reading command line response file',13,10,'$'
  1547. option_t_terminate_tx db   13,10,'Option -t set, Linux not loaded',13,10,'$'
  1548. option_t_forced_tx    db   13,10,'ERROR detected, Linux not loaded',13,10,'$'
  1549. err_in_config_sys_tx  db   13,10,'LOADLIN holding in idle loop (You must reboot)',13,10,'$'
  1550. ;-----------------------------------------------------------------------------
  1551. usage_tx  db  13,10
  1552.           db  'USAGE:',13,10
  1553.           db  '  LOADLIN @params',13,10
  1554.           db  '  LOADLIN [zimage_file] [options] [boot_params]',13,10
  1555.           db  '    without any params, LOADLIN displays this help message.',13,10
  1556.           db  '    @params:',13,10
  1557.           db  '       params is a DOS file containing all other options',13,10
  1558.           db  '    zimage_file:',13,10
  1559.           db  '       DOS file name of compressed Linux kernel image',13,10
  1560.           db  '    options:',13,10
  1561.           db  '       -v        verbose, show information on params and configuration',13,10
  1562.           db  '       -t        test mode, do all but starting Linux, also sets -v',13,10
  1563.           db  '       -d file   debug mode, same as -t, but duplicates output to "file"',13,10
  1564.           db  '       -rb       search for REALBIOS before BIOSINTV',13,10
  1565.           db  '       -rx       don''t check REALBIOS'' ROM-date',13,10
  1566.           db  "       -ja       use Javier's method, disable BIOSINTV and REALBIOS.",13,10
  1567.           db  "       -clone    ( Please read MANUAL.TXT before using this switch! )",13,10
  1568.           db  "       -oldxd    use old /dev/xda,xdb numbering 0xC00,0xC40",13,10
  1569.           db  "                 (newer kernels have 0xD00,0xD40)",13,10
  1570.           db  "       -n        no translation for root=/dev/...",13,10
  1571.           db  '    boot_params:',13,10
  1572.           db  '       root=xxx  filesystem to be mounted by Linux as "/"',13,10
  1573.           db  '            xxx = hex number (e.g. root=201 for /dev/fd1)',13,10
  1574.           db  '                = /dev/mmmn (e.g. root=/dev/hda2)',13,10
  1575.           db  '                       mmm = fd,hda,hdb,sda,sdb...',13,10
  1576.           db  '                       n   = 1..10.. decimal',13,10
  1577.           db  '                       n   = 01..0a.. or 0x1..0xa.. or a..f hexnumber',13,10
  1578.           db  '       ro        mount "/" readonly',13,10
  1579.           db  '       rw        mount "/" read/write',13,10
  1580.           db  '       ramdisk=x install ramdisk of size x Kbytes.  If also root=/dev/fdx,',13,10
  1581.           db  '                 then LOADLIN prompts for a floppy (copied into ramdisk)',13,10
  1582.           db  '       vga=xxx   vga mode (e.g. -3..0.., ask, normal, extended)',13,10
  1583.           db  '       (for more boot params see file PARAMS.DOC)',13,10
  1584. empty_tx  db  '$'
  1585.  
  1586.  
  1587.