home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 August (Alt) / CHIP 2005-08.1.iso / program / guvenlik / syslinux-3.07.exe / bootsect.inc < prev    next >
Encoding:
Text File  |  2005-01-11  |  3.6 KB  |  158 lines

  1. ;; $Id: bootsect.inc,v 1.15 2005/01/12 00:34:54 hpa Exp $
  2. ;; -----------------------------------------------------------------------
  3. ;;   
  4. ;;   Copyright 1994-2005 H. Peter Anvin - All Rights Reserved
  5. ;;
  6. ;;   This program is free software; you can redistribute it and/or modify
  7. ;;   it under the terms of the GNU General Public License as published by
  8. ;;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
  9. ;;   Boston MA 02111-1307, USA; either version 2 of the License, or
  10. ;;   (at your option) any later version; incorporated herein by reference.
  11. ;;
  12. ;; -----------------------------------------------------------------------
  13.  
  14. ;;
  15. ;; bootsect.inc
  16. ;; 
  17. ;; Load a boot sector (or other bootstrap program.)
  18. ;;
  19. ;; Unlike previous versions of this software, this doesn't require that
  20. ;; the length is 512 bytes.  This allows PXE bootstraps and WinNT
  21. ;; "CD boot sectors" to be invoked.
  22. ;;
  23.  
  24. ;
  25. ; Load a boot sector
  26. ;
  27. is_bootsector:
  28. %if IS_SYSLINUX || IS_MDSLINUX
  29.         ; Transfer zero bytes
  30.         mov byte [CopySuper],0
  31.         jmp short load_bootsec
  32.  
  33. is_bss_sector:
  34.         ; Transfer the superblock
  35.         mov byte [CopySuper],superblock_len
  36. %endif
  37. load_bootsec:
  38.         xchg dx,ax
  39.         shl eax,16
  40.         xchg dx,ax        ; Now EAX = file length
  41.         mov edi, 100000h
  42.         mov [trackbuf+4],edi    ; Copy from this address
  43.         push edi        ; Save load address
  44.         xor dx,dx        ; No padding
  45.         call load_high
  46.         call crlf
  47.  
  48.         sub edi,100000h
  49.         mov [trackbuf+8],edi    ; Save length
  50.  
  51.         mov eax,7C00h        ; Entry point
  52.         mov [trackbuf],eax    ; Copy to this address
  53.         mov [EntryPoint],eax    ; Jump to this address when done
  54.  
  55. %if IS_SYSLINUX || IS_MDSLINUX
  56.         movzx ecx,byte [CopySuper]
  57.         jcxz .not_bss
  58.  
  59.         ; For a BSS boot sector we have to patch.
  60.         mov esi,superblock
  61.         mov edi,100000h+(superblock-bootsec)
  62.         call bcopy
  63.  
  64. .not_bss:
  65. %endif
  66.  
  67.         xor edx,edx
  68.         xor esi,esi
  69. %if IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX
  70.         ; Restore original FDC table
  71.         mov eax,[OrigFDCTabPtr]
  72.         mov [fdctab],eax
  73.  
  74.         mov dl,[DriveNumber]
  75.         mov si,PartInfo        ; Partition info buffer
  76.         mov di,800h-18        ; Put partition info here
  77.         push di
  78.         mov cx,8        ; 16 bytes
  79.         xor ax,ax
  80.         rep movsw
  81.         pop si            ; DS:SI points to partition info
  82. %elif IS_ISOLINUX
  83.         mov dl,[DriveNo]
  84. %elif IS_PXELINUX
  85.         mov byte [KeepPXE],1    ; Chainloading another NBP
  86.         call reset_pxe
  87. %endif
  88.         xor bx,bx
  89.  
  90. ;
  91. ; replace_bootstrap for the special case where we have exactly one
  92. ; descriptor, and it's the first entry in the trackbuf
  93. ;
  94.  
  95. replace_bootstrap_one:
  96.         push word trackbuf        ; Address of descriptor list
  97.         push word 1            ; Length of descriptor list
  98.         ; Fall through
  99.  
  100. ; Entrypoint for "shut down and replace bootstrap" -- also invoked by
  101. ; the COMBOOT API.  This routine expects two words on the stack:
  102. ; address of the copy list (versus DS) and count.  Additionally,
  103. ; the values of ESI and EDX are passed on to the new bootstrap;
  104. ; the value of BX becomes the new DS.
  105. replace_bootstrap:
  106.         ;
  107.         ; Prepare for shutting down
  108.         ;
  109.         call vgaclearmode
  110.  
  111.         ;
  112.         ; Set up initial stack frame (not used by PXE if keeppxe is
  113.         ; set - we use the PXE stack then.)
  114.         ; AFTER THIS POINT ONLY .earlybss IS AVAILABLE, NOT .bss
  115.         ;
  116.         xor ax,ax
  117.         mov ds,ax
  118.         mov es,ax        
  119.  
  120. %if IS_PXELINUX
  121.         test byte [KeepPXE],01h
  122.         jz .stdstack
  123.         les di,[InitStack]    ; Reset stack to PXE original
  124.         jmp .stackok
  125. %endif
  126. .stdstack:
  127.         mov di,7C00h-44
  128.         push di
  129.         mov cx,22        ; 44 bytes
  130.         rep stosw
  131.         pop di
  132. .stackok:
  133.  
  134.         mov [es:di+28],edx
  135.         mov [es:di+12],esi
  136.         mov [es:di+6],bx
  137.  
  138.         pop ax            ; Copy list count
  139.         pop bx            ; Copy from...
  140.  
  141.         cli
  142.         mov cx,es
  143.         mov ss,cx
  144.         movzx esp,di
  145.  
  146.         jmp shuffle_and_boot
  147.  
  148. %if IS_SYSLINUX || IS_MDSLINUX
  149.         ; Nothing
  150. %else
  151. is_bss_sector:
  152.         mov si,err_bssimage
  153.         call cwritestr
  154.         jmp enter_command
  155. %endif
  156.