📄 grub-0.97-patch1-startups
字号:
++#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)++#define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)+#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE++/*+ * These are used to make use of C type-checking..+ */+extern int nx_enabled;+#ifdef CONFIG_X86_PAE+extern unsigned long long __supported_pte_mask;+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 pmd_val(x) ((x).pmd)+#define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))+#define __pmd(x) ((pmd_t) { (x) } )+#define HPAGE_SHIFT 21+#else+typedef struct { unsigned long pte_low; } pte_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)+#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA+#define ARCH_HAS_HUGETLB_CLEAN_STALE_PGTABLE+#endif++#define pgd_val(x) ((x).pgd)+#define pgprot_val(x) ((x).pgprot)++#define __pte(x) ((pte_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.+ */++#ifndef __ASSEMBLY__++/*+ * This much address space is reserved for vmalloc() and iomap()+ * as well as fixmap mappings.+ */+extern unsigned int __VMALLOC_RESERVE;++/* 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;+}++extern int sysctl_legacy_va_layout;++extern int page_is_ram(unsigned long pagenr);++#endif /* __ASSEMBLY__ */++#ifdef __ASSEMBLY__+#define __PAGE_OFFSET (0xC0000000)+#define __PHYSICAL_START CONFIG_PHYSICAL_START+#else+#define __PAGE_OFFSET (0xC0000000UL)+#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START)+#endif+#define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START)+++#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)+#ifdef CONFIG_FLATMEM+#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_FLATMEM */+#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.97/stage2/asm/segment.h grub-0.97_startups/stage2/asm/segment.h--- grub-0.97/stage2/asm/segment.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_startups/stage2/asm/segment.h 2006-10-24 12:28:50.000000000 +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 - ESPFIX small SS+ * 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_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)+#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)++#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++#endifdiff -Naur grub-0.97/stage2/asm/setup.h grub-0.97_startups/stage2/asm/setup.h--- grub-0.97/stage2/asm/setup.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_startups/stage2/asm/setup.h 2006-10-24 12:28:50.000000000 +0800@@ -0,0 +1,66 @@+/*+ * Just a place holder. We don't want to have to test x86 before+ * we include stuff+ */++#ifndef _i386_SETUP_H+#define _i386_SETUP_H++#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)+#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)+#define PFN_PHYS(x) ((x) << PAGE_SHIFT)++/*+ * Reserved space for vmalloc and iomap - defined in asm/page.h+ */+#define MAXMEM_PFN PFN_DOWN(MAXMEM)+#define MAX_NONPAE_PFN (1 << 20)++#define PARAM_SIZE 4096+#define COMMAND_LINE_SIZE 256++#define OLD_CL_MAGIC_ADDR 0x90020+#define OLD_CL_MAGIC 0xA33F+#define OLD_CL_BASE_ADDR 0x90000+#define OLD_CL_OFFSET 0x90022+#define NEW_CL_POINTER 0x228 /* Relative to real mode data */++#ifndef __ASSEMBLY__+/*+ * This is set up by the setup-routine at boot-time+ */+extern unsigned char boot_params[PARAM_SIZE];++#define PARAM (boot_params)+#define SCREEN_INFO (*(struct screen_info *) (PARAM+0))+#define EXT_MEM_K (*(unsigned short *) (PARAM+2))+#define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))+#define E820_MAP_NR (*(char*) (PARAM+E820NR))+#define E820_MAP ((struct e820entry *) (PARAM+E820MAP))+#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40))+#define IST_INFO (*(struct ist_info *) (PARAM+0x60))+#define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))+#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))+#define EFI_SYSTAB ((efi_system_table_t *) *((unsigned long *)(PARAM+0x1c4)))+#define EFI_MEMDESC_SIZE (*((unsigned long *) (PARAM+0x1c8)))+#define EFI_MEMDESC_VERSION (*((unsigned long *) (PARAM+0x1cc)))+#define EFI_MEMMAP ((efi_memory_desc_t *) *((unsigned long *)(PARAM+0x1d0)))+#define EFI_MEMMAP_SIZE (*((unsigned long *) (PARAM+0x1d4)))+#define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))+#define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))+#define VIDEO_MODE (*(unsigned short *) (PARAM+0x1FA))+#define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))+#define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))+#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))+#define KERNEL_START (*(unsigned long *) (PARAM+0x214))+#define INITRD_START (*(unsigned long *) (PARAM+0x218))+#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))+#define EDID_INFO (*(struct edid_info *) (PARAM+0x140))+#define EDD_NR (*(unsigned char *) (PARAM+EDDNR))+#define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF))+#define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF))+#define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF))++#endif /* __ASSEMBLY__ */++#endif /* _i386_SETUP_H */diff -Naur grub-0.97/stage2/boot.c grub-0.97_startups/stage2/boot.c--- grub-0.97/stage2/boot.c 2004-03-30 19:44:08.000000000 +0800+++ grub-0.97_startups/stage2/boot.c 2006-10-24 12:28:50.000000000 +0800@@ -64,7 +64,7 @@ if (!grub_open (kernel)) return KERNEL_TYPE_NONE; - if (!(len = grub_read (buffer, MULTIBOOT_SEARCH)) || len < 32)+ if (!(len = grub_read ((char *)buffer, MULTIBOOT_SEARCH)) || len < 32) { grub_close (); @@ -98,7 +98,7 @@ /* ELF loading supported if multiboot, FreeBSD and NetBSD. */ if ((type == KERNEL_TYPE_MULTIBOOT || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD- || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0+ || grub_strcmp ((const char *)(pu.elf->e_ident + EI_BRAND), "FreeBSD") == 0 || suggested_type == KERNEL_TYPE_NETBSD) && len > sizeof (Elf32_Ehdr) && BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer))))@@ -934,7 +934,7 @@ *arg = 0; while ((--arg) > (char *) MB_CMDLINE_BUF && *arg != '/'); if (*arg == '/')- bi.bi_kernelname = arg + 1;+ bi.bi_kernelname = (unsigned char *)arg + 1; else bi.bi_kernelname = 0; diff -Naur grub-0.97/stage2/bootlace.inc grub-0.97_startups/stage2/bootlace.inc--- grub-0.97/stage2/bootlace.inc 1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_startups/stage2/bootlace.inc 2006-10-24 12:28:50.000000000 +0800@@ -0,0 +1,3720 @@+/*+ * bootlace.inc -- code shared by 16-bit DOS and 32-bit Linux+ * Copyright (ABS(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.+ */++ .file "bootlace.inc"++#ifdef __DOS_16++#undef ABS+#define ABS(x) (x - _start + 0x100)++#undef iBX+#define iBX %bx++#undef iSI+#define iSI %si++#undef iDI+#define iDI %di++#undef iDX+#define iDX %dx++#undef LEAL+#define LEAL ADDR32 leal++#undef MOVZWL+#define MOVZWL ADDR32 movzwl++#undef MOVL+#define MOVL ADDR32 movl++#undef MOVW+#define MOVW ADDR32 movw++#undef CMPL+#define CMPL ADDR32 cmpl++#undef CMPW+#define CMPW ADDR32 cmpw++#undef SUBL+#define SUBL ADDR32 subl++#undef SBBL+#define SBBL ADDR32 sbbl++#undef NEGL+#define NEGL ADDR32 negl++#undef NOTL+#define NOTL ADDR32 notl++#undef ADCL+#define ADCL ADDR32 adcl++#undef DIVL+#define DIVL ADDR32 divl++ . = _start + 0x34 // dos entry point invalid_dos_exec ++#if 0+ movl $ABS(msg_invalid_dos), %ecx+ call 8f++ movw $0x4c01, %ax // EXIT - TERMINATE WITH RETURN CODE 1+ int $0x21 // call DOS+#else+ jmp 1f+#endif+++ //////////////////////////////////////////////////////////////////////+ + . = _start + 0x47 // dos entry point++1:+ /* dos entry point */++ movl $0x81, %esi+ movl %esi, %edi+ movl $0x7f, %ecx+ movb $0x0d, %al /* CR */++ cld+ repnz scasb++ decl %edi /* points to CR */+ std+ movb $0, %al+ stosb+ movl %edi, %esi+ xorl %ecx, %ecx+ pushl %ecx /* 0 is the end of argv */+ xorl %edx, %edx /* find spaces */+3:+ cmpl $0x81, %edi+ jb 3f+ lodsb+ cmpb $0x20, %al+ je 1f+ cmpb $0x09, %al+ jne 2f+1:+ testl %edx, %edx+ jz 1f+ notl %edx+ incl %edi+ pushl %edi /* argv */+ decl %edi+1:+ movb $0, %al+ stosb+ jmp 3b+2:+ testl %edx, %edx+ jnz 1f+ incl %ecx+ notl %edx+1:+ stosb+ jmp 3b+3:+ testl %edx, %edx+ jz 1f+ incl %edi+ pushl %edi+1:+ pushl %esi /* dummy for program name */+ incl %ecx+ pushl %ecx /* argc */+ cld+#else++#undef ABS+#define ABS(x) (x)++#undef iBX+#define iBX %ebx++#undef iSI+#define iSI %esi++#undef iDI+#define iDI %edi++#undef iDX+#define iDX %edx++#undef LEAL+#define LEAL leal++#undef MOVZWL+#define MOVZWL movzwl++#undef MOVL+#define MOVL movl++#undef MOVW+#define MOVW movw++#undef CMPL+#define CMPL cmpl++#undef CMPW+#define CMPW cmpw++#undef SUBL+#define SUBL subl++#undef SBBL+#define SBBL sbbl++#undef NEGL+#define NEGL negl++#undef NOTL+#define NOTL notl++#undef ADCL+#define ADCL adcl++#undef DIVL+#define DIVL divl++#endif++ popl %ecx # argc++ /* argc must be > 1 */++ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + cmpl $1, %ecx+ movl $ABS(msg_no_args), %ecx+ jbe 4f /* error */++ /* Note: ECX does not hold the argc now. */++ xorl %eax, %eax # EAX will point to file name+ //movl %ebx, ABS(filename) # save 0 to filename+ popl %ecx # discard argv[0], the program name+1:+ popl %ecx # argv+ movl %ecx, %ebx+ test %ecx, %ecx+ jz 1f # end of arguments++ /* check if it is an option */+ cmpb $0x2D, (iBX) # "-"+ jz 2f++ /* it is a filename */++ testl %eax, %eax # filename already specified?+ //cmpl $0, ABS(filename)+ jz 3f++ /* error: only one file should be specified. */+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -