📄 bootlacestart.s
字号:
/* * bootlacestart.S -- A utility for installing GRLDR boot sectors to MBR/OSBR * Copyright (C) 2005 Tinybit(tinybit@163.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* * This program is used to generate the GRLDR-INSTALL file. * * Use the following shell command to generate the GRLDR-INSTALL file: * * cp bootlacestart bootlace.com * *//* Use the following command to compile and build: * * gcc -o bootlacestart.exec -nostdlib -I. -I.. -I../stage1 -Wl,-N -Wl,-s bootlacestart.S * *///#define ABS(x) (x-_start+0x08048000)//#define ABS(x) (x)#define __DOT_COM .text .globl _start _start: /* command-line arguments: * bootlace.com [OPTIONS] DEVICE_OR_FILE */ # ELF header begin .byte 0x7F, 0x45, 0x4C, 0x46 # ELF magic number // 7F 45 = jg dos_entry_point // 4C = decw %sp // 46 = incw %si#if 0 .byte 0x01 # 32-bit .byte 0x01 # little-endian // 01 01 = addw %ax, (%bx, %di)#else .byte 0x01 # 32-bit .byte 0xC0 # corrupt-endian! # Sorry! # We have to use this for DOS code! // 01 C0 = addw %ax, %ax#endif .byte 0x01 # version#ifdef __DOT_COM .byte 0xC0 # pad char // 01 C0 = addw %ax, %ax //.byte 0xFA # pad char // // cli .byte 0x90 # pad char // nop .byte 0x44 # pad char // incw %sp //.byte 0xFB # pad char // // sti .byte 0x90 # pad char // nop .byte 0x4E # pad char // decw %si .byte 0x90 # pad char // nop .byte 0x90 # pad char // nop .byte 0xEB, 0x24 # pad char // jmp invalid_dos_exec#endif . = _start + 0x10 .word 2 # e_type = Executable .word 3 # e_machine = i386 .long 1 # e_version .long _start_linux # e_entry .long (_ph_offset - _start) # e_phoff .long (_sh_offset - _start) # e_shoff(section header table) .long 0 # e_flags .word 0x34 # e_ehsize (ELF header size) .word 0x20 # e_phentsize(prog header entry size) .word 1 # e_phnum(prog header entry count) .word 0x28 # e_shentsize .word 5 # e_shnum .word 4 # e_shstrndx # ELF header end . = _start + 0x34 // aux dos entry point#ifdef __DOT_COM//invalid_dos_exec: /* this is real mode dos code */ .code16#define __DOS_16#include "bootlace.inc"bios_drive_number: .long 0xff#if 0msg_invalid_dos: .ascii "\r\nError: Unsupported DOS. The DOS exec function call(int21/AX=4B00) did not\r\ntransfer flags of GREATER-THAN to this program. Report this problem to the\r\nmaintainers of GRUB FOR DOS.\r\n\r\n\0"#endif .align 0x10#endif_ph_offset: .long 1 # p_type .long (_start_linux - _start) # p_offset .long _start_linux # p_vaddr .long _start_linux # p_paddr .long (pre_stage2_start - _start_linux) # p_filesz .long (pre_stage2_start - _start_linux + (0x7E00 + 0x200)) # p_memszz .long 7 # p_flags .long 0x200 # p_align .align 0x200_start_linux: /* this is protected mode linux code */ .code32#undef __DOS_16#include "bootlace.inc"option_no_backup_mbr: .ascii "--no-backup-mbr\0"option_force_backup_mbr: .ascii "--force-backup-mbr\0"option_mbr_enable_floppy: .ascii "--mbr-enable-floppy\0"option_mbr_disable_floppy: .ascii "--mbr-disable-floppy\0"option_mbr_enable_osbr: .ascii "--mbr-enable-osbr\0"option_mbr_disable_osbr: .ascii "--mbr-disable-osbr\0"option_duce: .ascii "--duce\0"option_boot_prevmbr_first: .ascii "--boot-prevmbr-first\0"option_boot_prevmbr_last: .ascii "--boot-prevmbr-last\0"option_preferred_drive: .ascii "--preferred-drive=\0"option_preferred_partition: .ascii "--preferred-partition=\0"option_install_partition: .ascii "--install-partition=\0"option_sectors_per_track: .ascii "--sectors-per-track=\0"option_heads: .ascii "--heads=\0"option_start_sector: .ascii "--start-sector=\0"option_total_sectors: .ascii "--total-sectors=\0"option_floppy_partition: .ascii "--floppy=\0"option_time_out: .ascii "--time-out=\0"option_hot_key: .ascii "--hot-key=\0"option_read_only: .ascii "--read-only\0"option_floppy: .ascii "--floppy\0"option_lba: .ascii "--lba\0"option_chs: .ascii "--chs\0"option_fat12: .ascii "--fat12\0"option_fat16: .ascii "--fat16\0"option_fat32: .ascii "--fat32\0"option_ntfs: .ascii "--ntfs\0"option_ext2: .ascii "--ext2\0"option_vfat: .ascii "--vfat\0"msg_start: /* messages begins at here */msg_no_args: .ascii "\r\nError: No command-line arguments specified.\r\n\r\n\0"msg_too_many_files: .ascii "\r\nError: More than one files specified.\r\n\r\n\0"msg_no_file: .ascii "\r\nError: No device or file specified.\r\n\r\n\0"msg_option_backup_mbr: .ascii "\r\nError: Specified an option twice for backing up MBR.\r\n\r\n\0"msg_option_backup_mbr_with_floppy: .ascii "\r\nError: Specified --floppy with backing up MBR.\r\n\r\n\0"msg_option_backup_mbr_with_partition: .ascii "\r\nError: Specified --install-partition with backing up MBR.\r\n\r\n\0"msg_option_mbr_floppy: .ascii "\r\nError: Specified an option twice for searching floppy.\r\n\r\n\0"msg_option_mbr_floppy_with_floppy: .ascii "\r\nError: Specified --floppy with MBR searching floppy.\r\n\r\n\0"msg_option_mbr_floppy_with_partition: .ascii "\r\nError: Specified --install-partition with MBR searching floppy.\r\n\r\n\0"msg_option_mbr_osbr: .ascii "\r\nError: Specified an option twice for booting osbr.\r\n\r\n\0"msg_option_mbr_osbr_with_floppy: .ascii "\r\nError: Specified --floppy with booting osbr.\r\n\r\n\0"msg_option_mbr_osbr_with_partition: .ascii "\r\nError: Specified --install-partition with booting osbr.\r\n\r\n\0"msg_option_duce: .ascii "\r\nError: Specified --duce twice.\r\n\r\n\0"msg_option_duce_with_floppy: .ascii "\r\nError: Specified --floppy with --duce.\r\n\r\n\0"msg_option_duce_with_partition: .ascii "\r\nError: Specified --install-partition with --duce.\r\n\r\n\0"msg_option_boot_prevmbr: .ascii "\r\nError: Specified an option twice for booting prevmbr.\r\n\r\n\0"msg_option_boot_prevmbr_with_floppy: .ascii "\r\nError: Specified --floppy with booting prevmbr.\r\n\r\n\0"msg_option_boot_prevmbr_with_partition: .ascii "\r\nError: Specified --install-partition with booting prevmbr.\r\n\r\n\0"msg_option_preferred_drive: .ascii "\r\nError: Specified an option twice for preferred drive.\r\n\r\n\0"msg_option_preferred_drive_with_floppy: .ascii "\r\nError: Specified --floppy with preferred drive.\r\n\r\n\0"msg_option_preferred_drive_with_partition: .ascii "\r\nError: Specified --install-partition with preferred drive.\r\n\r\n\0"msg_option_preferred_partition: .ascii "\r\nError: Specified an option twice for preferred partition.\r\n\r\n\0"msg_option_preferred_partition_with_floppy: .ascii "\r\nError: Specified --floppy with preferred partition.\r\n\r\n\0"msg_option_preferred_partition_with_partition: .ascii "\r\nError: Specified --install-partition with preferred partition.\r\n\r\n\0"msg_option_install_partition: .ascii "\r\nError: Specified an option twice for install partition.\r\n\r\n\0"msg_option_install_partition_with_floppy: .ascii "\r\nError: Specified --floppy with install partition.\r\n\r\n\0"msg_option_install_partition_not_implemented: .ascii "\r\nSorry! --install-partition not yet implemented with this release.\r\n\r\n\0"msg_option_time_out: .ascii "\r\nError: Specified an option twice for time out.\r\n\r\n\0"msg_option_time_out_with_floppy: .ascii "\r\nError: Specified --floppy with time out.\r\n\r\n\0"msg_option_time_out_with_partition: .ascii "\r\nError: Specified --install-partition with time out.\r\n\r\n\0"msg_option_time_out_without_prevmbr: .ascii "\r\nError: Specified --time-out without specifying --boot-prevmbr-first.\r\n\r\n\0"msg_option_hot_key: .ascii "\r\nError: Specified an option twice for hot key.\r\n\r\n\0"msg_option_hot_key_with_floppy: .ascii "\r\nError: Specified --floppy with hot key.\r\n\r\n\0"msg_option_hot_key_with_partition: .ascii "\r\nError: Specified --install-partition with hot key.\r\n\r\n\0"msg_option_hot_key_without_prevmbr: .ascii "\r\nError: Specified --hot-key without specifying --boot-prevmbr-first.\r\n\r\n\0"msg_option_sectors_per_track: .ascii "\r\nError: Specified an option twice for sectors per track.\r\n\r\n\0"msg_option_sectors_per_track_with_partition: .ascii "\r\nError: Specified --install-partition with sectors per track.\r\n\r\n\0"msg_option_sectors_per_track_for_mbr: .ascii "\r\nError: Specified --sectors-per-track for a hard drive.\r\n\r\n\0"msg_option_heads: .ascii "\r\nError: Specified an option twice for heads.\r\n\r\n\0"msg_option_heads_with_partition: .ascii "\r\nError: Specified --install-partition with --heads.\r\n\r\n\0"msg_option_heads_for_mbr: .ascii "\r\nError: Specified --heads for a hard drive.\r\n\r\n\0"msg_option_start_sector: .ascii "\r\nError: Specified an option twice for start sector.\r\n\r\n\0"msg_option_start_sector_with_partition: .ascii "\r\nError: Specified --install-partition with --start-sector.\r\n\r\n\0"msg_option_start_sector_for_mbr: .ascii "\r\nError: Specified --start-sector for a hard drive.\r\n\r\n\0"msg_option_total_sectors: .ascii "\r\nError: Specified an option twice for total sectors.\r\n\r\n\0"msg_option_total_sectors_with_partition: .ascii "\r\nError: Specified --install-partition with --total-sectors.\r\n\r\n\0"msg_option_total_sectors_for_mbr: .ascii "\r\nError: Specified --total-sectors for a hard drive.\r\n\r\n\0"msg_option_read_only: .ascii "\r\nError: Specified an option twice for read only.\r\n\r\n\0"msg_option_floppy: .ascii "\r\nError: Specified an option twice for --floppy.\r\n\r\n\0"msg_option_lba: .ascii "\r\nError: Specified an option twice for lba-chs mode.\r\n\r\n\0"msg_option_lba_for_mbr: .ascii "\r\nError: Specified --lba for a hard drive.\r\n\r\n\0"msg_option_fstypes_for_mbr: .ascii "\r\nError: Specified file system types for a hard-drive mbr device.\r\n\r\n\0"msg_partition_without_drive: .ascii "\r\nError: Preferred partition without preferred drive.\r\n\r\n\0"msg_partition_start: .ascii "\r\nError: For a single partition you must specify --start-sector to non-zero.\r\n\r\n\0"msg_floppy_start: .ascii "\r\nError: For a real floppy you must specify --start-sector to 0.\r\n\r\n\0"msg_invalid_number: .ascii "\r\nError: Invalid number format or invalid value for the specified option.\r\n\r\n\0"msg_invalid_option: .ascii "\r\nError: Invalid option.\r\n\r\n\0"msg_open_file_rw: .ascii "\r\nError: Cannot open file for read/write access.\r\n\r\n\0"msg_open_file_ro: .ascii "\r\nError: Cannot open file for read-only access.\r\n\r\n\0"msg_read_file: .ascii "\r\nError: Read file failed.\r\n\r\n\0"msg_lseek_file: .ascii "\r\nError: Rewind file(lseek) failed.\r\n\r\n\0"msg_write_file: .ascii "\r\nError: Write file failed.\r\n\r\n\0"msg_close_file: .ascii "\r\nFatal! Close file failed. Please backup your disk in case it becomes unusable.\r\n\r\n\0"msg_boot_signature_mbr: .ascii "\r\nError: No boot signature(55 AA). Must specify --floppy explicitly for floppy.\r\n\r\n\0"msg_invalid_partition_table: .ascii "\r\nError: Invalid partition table. Must specify --floppy explicitly for floppy.\r\n\r\n\0"msg_floppy_partition_table: .ascii "\r\nError: Specified --floppy for DEVICE_OR_FILE that has a valid partition table.\r\n\r\n\0"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -