📄 grub-0.95-patch1-startups
字号:
diff -Naur grub-0.95/ChangeLog grub-0.95_startups/ChangeLog--- grub-0.95/ChangeLog 2004-06-14 01:52:57.000000000 +0800+++ grub-0.95_startups/ChangeLog 2004-10-22 14:03:21.327886608 +0800@@ -1,3 +1,24 @@+2004-07-13++ From Tinybit <tinybit@163.net>:+ For booting via DOS/NTLDR:+ * stage2/Makefile.am: added items for GRLDR, GRUB.EXE and GRUB4LIN++ * stage2/grldrstart.S: (new file) startup code for GRLDR(boot via NT)++ * stage2/dosstart.S: (new file) startup code for GRUB.EXE(boot via DOS)++ * stage2/grub4linstart.S: (new file) startup code for GRUB4LIN(boot+ via kexec/LILO/GRUB)++ * stage2/edd.S: (new file) for being included by grub4linstart.S++ * stage2/video.S: (new file) for being included by grub4linstart.S++ * stage2/asm: (new dir) contains header files for grub4linstart.S++ * stage2/linux: (new dir) contains header files for grub4linstart.S+ 2004-06-13 Yoshinori K. Okuji <okuji@enbug.org> * configure.ac (AC_INIT): Upgraded to 0.95.diff -Naur grub-0.95/stage2/asm/boot.h grub-0.95_startups/stage2/asm/boot.h--- grub-0.95/stage2/asm/boot.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/asm/boot.h 2004-10-21 21:17:28.054216000 +0800@@ -0,0 +1,15 @@+#ifndef _LINUX_BOOT_H+#define _LINUX_BOOT_H++/* Don't touch these, unless you really know what you're doing. */+#define DEF_INITSEG 0x9000+#define DEF_SYSSEG 0x1000+#define DEF_SETUPSEG 0x9020+#define DEF_SYSSIZE 0x7F00++/* Internal svga startup constants */+#define NORMAL_VGA 0xffff /* 80x25 mode */+#define EXTENDED_VGA 0xfffe /* 80x50 mode */+#define ASK_VGA 0xfffd /* ask for it at bootup */++#endifdiff -Naur grub-0.95/stage2/asm/e820.h grub-0.95_startups/stage2/asm/e820.h--- grub-0.95/stage2/asm/e820.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/asm/e820.h 2004-10-21 20:58:31.115057000 +0800@@ -0,0 +1,40 @@+/*+ * structures and definitions for the int 15, ax=e820 memory map+ * scheme.+ *+ * In a nutshell, arch/i386/boot/setup.S populates a scratch table+ * in the empty_zero_block that contains a list of usable address/size+ * duples. In arch/i386/kernel/setup.c, this information is+ * transferred into the e820map, and in arch/i386/mm/init.c, that+ * new information is used to mark pages reserved or not.+ *+ */+#ifndef __E820_HEADER+#define __E820_HEADER++#define E820MAP 0x2d0 /* our map */+#define E820MAX 32 /* number of entries in E820MAP */+#define E820NR 0x1e8 /* # entries in E820MAP */++#define E820_RAM 1+#define E820_RESERVED 2+#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */+#define E820_NVS 4++#define HIGH_MEMORY (1024*1024)++#ifndef __ASSEMBLY__++struct e820map {+ int nr_map;+ struct e820entry {+ unsigned long long addr; /* start of memory segment */+ unsigned long long size; /* size of memory segment */+ unsigned long type; /* type of memory segment */+ } map[E820MAX];+};++extern struct e820map e820;+#endif/*!__ASSEMBLY__*/++#endif/*__E820_HEADER*/diff -Naur grub-0.95/stage2/asm/linkage.h grub-0.95_startups/stage2/asm/linkage.h--- grub-0.95/stage2/asm/linkage.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/asm/linkage.h 2004-10-21 21:36:21.790862000 +0800@@ -0,0 +1,13 @@+#ifndef __ASM_LINKAGE_H+#define __ASM_LINKAGE_H++#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))+#define FASTCALL(x) x __attribute__((regparm(3)))+#define fastcall __attribute__((regparm(3)))++#ifdef CONFIG_X86_ALIGNMENT_16+#define __ALIGN .align 16,0x90+#define __ALIGN_STR ".align 16,0x90"+#endif++#endifdiff -Naur grub-0.95/stage2/asm/page.h grub-0.95_startups/stage2/asm/page.h--- grub-0.95/stage2/asm/page.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/asm/page.h 2004-10-21 20:58:39.175832000 +0800@@ -0,0 +1,150 @@+#ifndef _I386_PAGE_H+#define _I386_PAGE_H++/* PAGE_SHIFT determines the page size */+#define PAGE_SHIFT 12+#define PAGE_SIZE (1UL << PAGE_SHIFT)+#define PAGE_MASK (~(PAGE_SIZE-1))++#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))+#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)++#ifdef __KERNEL__+#ifndef __ASSEMBLY__++#include <linux/config.h>++#ifdef CONFIG_X86_USE_3DNOW++#include <asm/mmx.h>++#define clear_page(page) mmx_clear_page((void *)(page))+#define copy_page(to,from) mmx_copy_page(to,from)++#else++/*+ * On older X86 processors it's not a win to use MMX here it seems.+ * Maybe the K6-III ?+ */+ +#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)+#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)++#endif++#define clear_user_page(page, vaddr, pg) clear_page(page)+#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)++/*+ * These are used to make use of C type-checking..+ */+#ifdef CONFIG_X86_PAE+extern unsigned long long __supported_pte_mask;+extern int nx_enabled;+typedef struct { unsigned long pte_low, pte_high; } pte_t;+typedef struct { unsigned long long pmd; } pmd_t;+typedef struct { unsigned long long pgd; } pgd_t;+typedef struct { unsigned long long pgprot; } pgprot_t;+#define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))+#define HPAGE_SHIFT 21+#else+#define nx_enabled 0+typedef struct { unsigned long pte_low; } pte_t;+typedef struct { unsigned long pmd; } pmd_t;+typedef struct { unsigned long pgd; } pgd_t;+typedef struct { unsigned long pgprot; } pgprot_t;+#define boot_pte_t pte_t /* or would you rather have a typedef */+#define pte_val(x) ((x).pte_low)+#define HPAGE_SHIFT 22+#endif+#define PTE_MASK PAGE_MASK++#ifdef CONFIG_HUGETLB_PAGE+#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)+#define HPAGE_MASK (~(HPAGE_SIZE - 1))+#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)+#endif+++#define pmd_val(x) ((x).pmd)+#define pgd_val(x) ((x).pgd)+#define pgprot_val(x) ((x).pgprot)++#define __pte(x) ((pte_t) { (x) } )+#define __pmd(x) ((pmd_t) { (x) } )+#define __pgd(x) ((pgd_t) { (x) } )+#define __pgprot(x) ((pgprot_t) { (x) } )++#endif /* !__ASSEMBLY__ */++/* to align the pointer to the (next) page boundary */+#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)++/*+ * This handles the memory map.. We could make this a config+ * option, but too many people screw it up, and too few need+ * it.+ *+ * A __PAGE_OFFSET of 0xC0000000 means that the kernel has+ * a virtual address space of one gigabyte, which limits the+ * amount of physical memory you can use to about 950MB. + *+ * If you want more physical memory than this then see the CONFIG_HIGHMEM4G+ * and CONFIG_HIGHMEM64G options in the kernel configuration.+ */++/*+ * This much address space is reserved for vmalloc() and iomap()+ * as well as fixmap mappings.+ */+#define __VMALLOC_RESERVE (128 << 20)++#ifndef __ASSEMBLY__++/* Pure 2^n version of get_order */+static __inline__ int get_order(unsigned long size)+{+ int order;++ size = (size-1) >> (PAGE_SHIFT-1);+ order = -1;+ do {+ size >>= 1;+ order++;+ } while (size);+ return order;+}++#endif /* __ASSEMBLY__ */++#ifdef __ASSEMBLY__+#define __PAGE_OFFSET (0xC0000000)+#else+#define __PAGE_OFFSET (0xC0000000UL)+#endif+++#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)+#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)+#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)+#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)+#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))+#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)+#ifndef CONFIG_DISCONTIGMEM+#define pfn_to_page(pfn) (mem_map + (pfn))+#define page_to_pfn(page) ((unsigned long)((page) - mem_map))+#define pfn_valid(pfn) ((pfn) < max_mapnr)+#endif /* !CONFIG_DISCONTIGMEM */+#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)++#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)++#define VM_DATA_DEFAULT_FLAGS \+ (VM_READ | VM_WRITE | \+ ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \+ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)++#endif /* __KERNEL__ */++#endif /* _I386_PAGE_H */diff -Naur grub-0.95/stage2/asm/segment.h grub-0.95_startups/stage2/asm/segment.h--- grub-0.95/stage2/asm/segment.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/asm/segment.h 2004-10-21 20:58:16.629259000 +0800@@ -0,0 +1,101 @@+#ifndef _ASM_SEGMENT_H+#define _ASM_SEGMENT_H++/*+ * The layout of the per-CPU GDT under Linux:+ *+ * 0 - null+ * 1 - reserved+ * 2 - reserved+ * 3 - reserved+ *+ * 4 - unused <==== new cacheline+ * 5 - unused+ *+ * ------- start of TLS (Thread-Local Storage) segments:+ *+ * 6 - TLS segment #1 [ glibc's TLS segment ]+ * 7 - TLS segment #2 [ Wine's %fs Win32 segment ]+ * 8 - TLS segment #3+ * 9 - reserved+ * 10 - reserved+ * 11 - reserved+ *+ * ------- start of kernel segments:+ *+ * 12 - kernel code segment <==== new cacheline+ * 13 - kernel data segment+ * 14 - default user CS+ * 15 - default user DS+ * 16 - TSS+ * 17 - LDT+ * 18 - PNPBIOS support (16->32 gate)+ * 19 - PNPBIOS support+ * 20 - PNPBIOS support+ * 21 - PNPBIOS support+ * 22 - PNPBIOS support+ * 23 - APM BIOS support+ * 24 - APM BIOS support+ * 25 - APM BIOS support + *+ * 26 - unused+ * 27 - unused+ * 28 - unused+ * 29 - unused+ * 30 - unused+ * 31 - TSS for double fault handler+ */+#define GDT_ENTRY_TLS_ENTRIES 3+#define GDT_ENTRY_TLS_MIN 6+#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)++#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)++#define GDT_ENTRY_DEFAULT_USER_CS 14+#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)++#define GDT_ENTRY_DEFAULT_USER_DS 15+#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)++#define GDT_ENTRY_KERNEL_BASE 12++#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)+#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)++#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)+#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)++#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)+#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)++#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6)+#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11)++#define GDT_ENTRY_DOUBLEFAULT_TSS 31++/*+ * The GDT has 32 entries+ */+#define GDT_ENTRIES 32++#define GDT_SIZE (GDT_ENTRIES * 8)++/* Simple and small GDT entries for booting only */++#define GDT_ENTRY_BOOT_CS 2+#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)++#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)+#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)++/*+ * The interrupt descriptor table has room for 256 idt's,+ * the global descriptor table is dependent on the number+ * of tasks we can have..+ */+#define IDT_ENTRIES 256++#define LOAD_ADDRESS (CONFIG_LOAD_ADDRESS_MB * 0x100000)++#endif+diff -Naur grub-0.95/stage2/dosstart.S grub-0.95_startups/stage2/dosstart.S--- grub-0.95/stage2/dosstart.S 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/dosstart.S 2004-10-22 13:26:59.883516560 +0800@@ -0,0 +1,1665 @@+/*+ * dosstart.S -- DOS EXE-header and startup code for GNU GRUB+ * Copyright (C) 2003 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 grub.exe file, which runs off DOS.+ *+ * Use the following shell command to generate the grub.exe file:+ *+ * cat dosstart pre_stage2 > grub.exe+ *+ */++#define ASM_FILE+#include <shared.h>+#include <stage2_size.h>+ +#define DOSSTART_SIZE 0x1200 /* should be sector-aligned, i.e., (n * 0x200) */++#define ABS_PSP(x) (x-_start-0x100)+#define ABS_START(x) (x-_start-0x200)+#define ABS_FINAL(x) (x-_start-DOSSTART_SIZE+0x200)++#define exe_last_sector_size ((STAGE2_SIZE + DOSSTART_SIZE) % 512)+#define exe_sectors ((STAGE2_SIZE + DOSSTART_SIZE + 511) / 512 )+ + .file "dosstart.S"++ .text++ /* Tell GAS to generate 16-bit instructions so that this code works+ in real mode. */+ .code16++ .globl start, _start+start:+_start:+ /*+ * The dos startup code counts 9 sectors:+ *+ * 1 sector for DOS EXE header, followed by 8 sectors of code.+ * Of the 8 code sectors, the first 7 sectors are preparational+ * sectors, and the last sector is called the FINAL sector. The+ * FINAL sector contains code that finally launches the stage2 code.+ * So pay special attention to the FINAL sector. Do not destroy+ * the FINAL sector upon memory move operations.+ */++ .byte 0x4d, 0x5a /* 'MZ', the EXE magic number. */+ .word exe_last_sector_size /* EXE file last sector in bytes */+ .word exe_sectors /* total sectors the EXE file occupies */+ .word 0 /* relocation table entries */+ .word 0x0020 /* header size in 16-byte sections.+ 0x0020 sections == 512 bytes */+ .word 0x0400 /* MinAlloc sections, 16KByte room for+ extended BIOS data area */+ .word 0x0400 /* MaxAlloc sections, no more memory needed,+ so MaxAlloc == MinAlloc */+ .word 0 /* initial SS, relative to the so-called START+ segment */+ .word ABS_START(just_here) /* initial SP, points to displacement 0x180+ in the FINAL sector */+ .word 0 /* checksum, ignored by dos */+ .word 0 /* initial IP */+ .word 0 /* initial CS, relative to START segment */+ .word 0x0020 /* displacement of the relocation table */+ .word 0 /* overlay serial number. 0 for main program */++ . = 0x200 /* program goes here, DS==ES==PSP, CS==SS==START */++ cli /* we have not much room for stack, so we cli */++ movw $0x0081, %di /* get command line */+ movw $0x007f, %cx /* max length of command line */+ cld /* scan upward */+ movb $0x20, %al /* the space bar character */+ repz scasb /* skip all space chars */+ decw %di /* points to the command line arguments */+ cmpb $0x2f, (%di) /* check if the leading char is a slash */+ jne 1f /* no, continue */+ stosb /* change the leading slash to space bar */++ /* change all the rest chars to space bar, up to the pair "--" */+2:+ cmpb $0x20, (%di) /* check if the next char is printable */+ jb 1f /* no, continue */+ cmpw $0x2d2d, (%di) /* check if the next pair is "--" */+ je 1f /* yes, continue */+ stosb /* change the char to space bar */+ loop 2b++ /* find the space-slash pair and change the space to CR */+1:+ movw $0x0081, %di /* get command line */+ movw $0x007f, %cx /* max length of command line */+ cld /* scan upward */+ movb $0x20, %al /* the space bar character */+1:+ repnz scasb /* find the space char */+ jcxz 1f /* not found, continue */+ cmpb $0x2f, (%di) /* is it the " /" pair */+ jnz 1b /* no, search the rest of the command line */+ decw %di+ movb $0x0d, %al /* mark the end of command line */+ stosb /* change the space to CR */+1:+ movw $0x0081, %di /* get command line */+ movb $0x7f, %cl /* max length of command line */+ movb $0x20, %al /* the space bar character */+ repz scasb /* skip all space chars */+ decw %di /* points to the command line arguments */+ cmpb $0x0d, (%di) /* CR char means empty command line */+ jbe use_default_config_file+ movw $ABS_PSP(option_config_file), %si+ movw %si, %bx+ movw %di, %dx+ movb $0x0e, %cl+ //cld+ repz cmpsb+ jz 1f+ movb $0x7f, %cl+ movw %dx, %si+ movw %dx, %di+2:+ lodsb+ cmpb $0x0d, %al /* chars less than 0x0d is considered ... */+ ja 3f+ movb $0x0d, %al /* ... to be the end of the command-line */ + stosb /* change the end mark to 0x0d */+ jmp 2f+3:+ cmpb $0x41, %al+ jb 3f+ cmpb $0x5a, %al+ ja 3f+ orb $0x20, %al+3:+ stosb+ loop 2b+2:+ movb $0x0e, %cl+ movw %bx, %si+ movw %dx, %di+ //cld+ repz cmpsb+ jnz invalid_option+1:+ movw %di, %si /* points to the config file name */+ movb $0x7f, %cl+ movb $0x0d, %al /* find the end of command line, CR */+ //cld+ repnz scasb+ movw %di, %cx /* points to config file name in stage2 */+ subw %si, %cx+ decw %cx /* length of config file name */++put_config_file_name:+ pushw %cx+ movw $0x0010, %cx /* set max length of grub version string */+ movw $ABS_PSP(end_dosstart+0x12), %di /* version string */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -