syslinux/core/localboot.inc
<<
>>
Prefs
   1; -----------------------------------------------------------------------
   2;
   3;   Copyright 1999-2008 H. Peter Anvin - All Rights Reserved
   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, Inc., 51 Franklin St, Fifth Floor,
   8;   Boston MA 02110-1301, USA; either version 2 of the License, or
   9;   (at your option) any later version; incorporated herein by reference.
  10;
  11; -----------------------------------------------------------------------
  12
  13;
  14; localboot.inc
  15;
  16; Boot from a local disk, or invoke INT 18h.
  17;
  18
  19;
  20; Boot a specified local disk.  AX specifies the BIOS disk number; or
  21; -1 in case we should execute INT 18h ("next device.")
  22;
  23                section .text16
  24
  25local_boot:
  26                call vgaclearmode
  27                RESET_STACK_AND_SEGS dx         ; dx <- 0
  28                mov fs,dx
  29                mov gs,dx
  30                mov si,localboot_msg
  31                call writestr
  32                call cleanup_hardware
  33                cmp ax,-1
  34                je .int18
  35
  36                ; Load boot sector from the specified BIOS device and jump to it.
  37                mov dl,al
  38                xor dh,dh
  39                push dx
  40                xor ax,ax                       ; Reset drive
  41                int 13h
  42                mov ax,0201h                    ; Read one sector
  43                mov cx,0001h                    ; C/H/S = 0/0/1 (first sector)
  44                mov bx,trackbuf
  45                mov bp,retry_count
  46.again:
  47                pusha
  48                int 13h
  49                popa
  50                jnc .ok
  51                dec bp
  52                jnz .again
  53                jmp kaboom                      ; Failure...
  54.ok:
  55                pop dx
  56                cli                             ; Abandon hope, ye who enter here
  57                mov si,trackbuf
  58                mov di,07C00h
  59                mov cx,512                      ; Probably overkill, but should be safe
  60                rep movsd
  61                mov ss,cx                       ; SS <- 0
  62                mov sp,7C00h
  63                jmp 0:07C00h                    ; Jump to new boot sector
  64
  65.int18:
  66                int 18h                         ; Hope this does the right thing...
  67                jmp kaboom                      ; If we returned, oh boy...
  68
  69                section .data16
  70localboot_msg   db 'Booting from local disk...', CR, LF, 0
  71
  72                section .text16
  73
  74
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.