diff options
author | jhb <jhb@FreeBSD.org> | 2009-03-09 17:16:29 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-03-09 17:16:29 +0000 |
commit | 6e59eb909741886dca69874a80b8e29e463957e6 (patch) | |
tree | de3bcd606d22f35302dfe3ccf5de4d0f51c0be82 /sys | |
parent | b95f7329df6e4c18574c02802a132848e5955244 (diff) | |
download | FreeBSD-src-6e59eb909741886dca69874a80b8e29e463957e6.zip FreeBSD-src-6e59eb909741886dca69874a80b8e29e463957e6.tar.gz |
- Make it possible to disable GPT support by setting LOADER_NO_GPT_SUPPORT
in make.conf or src.conf.
- When GPT is enabled (which it is by default), use memory above 1 MB and
leave the memory from the end of the bss to the end of the 640k window
purely for the stack. The loader has grown and now it is much more
common for the heap and stack to grow into each other when both are
located in the 640k window.
PR: kern/129526
MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r-- | sys/boot/i386/libi386/Makefile | 4 | ||||
-rw-r--r-- | sys/boot/i386/libi386/biosdisk.c | 26 | ||||
-rw-r--r-- | sys/boot/i386/libi386/devicename.c | 8 | ||||
-rw-r--r-- | sys/boot/i386/loader/Makefile | 3 | ||||
-rw-r--r-- | sys/boot/i386/loader/main.c | 2 |
5 files changed, 40 insertions, 3 deletions
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile index b084733..3430bef 100644 --- a/sys/boot/i386/libi386/Makefile +++ b/sys/boot/i386/libi386/Makefile @@ -33,6 +33,10 @@ CFLAGS+= -DDISK_DEBUG CFLAGS+= -DSMBIOS_SERIAL_NUMBERS .endif +.if !defined(LOADER_NO_GPT_SUPPORT) +CFLAGS+= -DLOADER_GPT_SUPPORT +.endif + # Include simple terminal emulation (cons25-compatible) CFLAGS+= -DTERM_EMU diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index 45c8cd8..9d31325 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -68,12 +68,14 @@ __FBSDID("$FreeBSD$"); # define DEBUG(fmt, args...) #endif +#ifdef LOADER_GPT_SUPPORT struct gpt_part { int gp_index; uuid_t gp_type; uint64_t gp_start; uint64_t gp_end; }; +#endif struct open_disk { int od_dkunit; /* disk unit number */ @@ -90,25 +92,31 @@ struct open_disk { #define BD_FLOPPY 0x0004 #define BD_LABELOK 0x0008 #define BD_PARTTABOK 0x0010 +#ifdef LOADER_GPT_SUPPORT #define BD_GPTOK 0x0020 +#endif union { struct { struct disklabel mbr_disklabel; int mbr_nslices; /* slice count */ struct dos_partition mbr_slicetab[NEXTDOSPART]; } _mbr; +#ifdef LOADER_GPT_SUPPORT struct { int gpt_nparts; struct gpt_part *gpt_partitions; } _gpt; +#endif } _data; }; #define od_disklabel _data._mbr.mbr_disklabel #define od_nslices _data._mbr.mbr_nslices #define od_slicetab _data._mbr.mbr_slicetab +#ifdef LOADER_GPT_SUPPORT #define od_nparts _data._gpt.gpt_nparts #define od_partitions _data._gpt.gpt_partitions +#endif /* * List of BIOS devices, translation from disk unit number to @@ -130,8 +138,10 @@ static int bd_write(struct open_disk *od, daddr_t dblk, int blks, static int bd_int13probe(struct bdinfo *bd); +#ifdef LOADER_GPT_SUPPORT static void bd_printgptpart(struct open_disk *od, struct gpt_part *gp, char *prefix, int verbose); +#endif static void bd_printslice(struct open_disk *od, struct dos_partition *dp, char *prefix, int verbose); static void bd_printbsdslice(struct open_disk *od, daddr_t offset, @@ -163,8 +173,10 @@ static void bd_closedisk(struct open_disk *od); static int bd_open_mbr(struct open_disk *od, struct i386_devdesc *dev); static int bd_bestslice(struct open_disk *od); static void bd_checkextended(struct open_disk *od, int slicenum); +#ifdef LOADER_GPT_SUPPORT static int bd_open_gpt(struct open_disk *od, struct i386_devdesc *dev); static struct gpt_part *bd_best_gptpart(struct open_disk *od); +#endif /* * Translate between BIOS device numbers and our private unit numbers. @@ -286,6 +298,7 @@ bd_print(int verbose) if (!bd_opendisk(&od, &dev)) { +#ifdef LOADER_GPT_SUPPORT /* Do we have a GPT table? */ if (od->od_flags & BD_GPTOK) { for (j = 0; j < od->od_nparts; j++) { @@ -293,9 +306,10 @@ bd_print(int verbose) od->od_partitions[j].gp_index); bd_printgptpart(od, &od->od_partitions[j], line, verbose); } - + } else +#endif /* Do we have a partition table? */ - } else if (od->od_flags & BD_PARTTABOK) { + if (od->od_flags & BD_PARTTABOK) { dptr = &od->od_slicetab[0]; /* Check for a "dedicated" disk */ @@ -339,6 +353,7 @@ display_size(uint64_t size) return (buf); } +#ifdef LOADER_GPT_SUPPORT static uuid_t efi = GPT_ENT_TYPE_EFI; static uuid_t freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT; static uuid_t freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS; @@ -380,6 +395,7 @@ bd_printgptpart(struct open_disk *od, struct gpt_part *gp, char *prefix, stats); pager_output(line); } +#endif /* * Print information about slices on a disk. For the size calculations we @@ -561,8 +577,10 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev) } /* Determine disk layout. */ +#ifdef LOADER_GPT_SUPPORT error = bd_open_gpt(od, dev); if (error) +#endif error = bd_open_mbr(od, dev); out: @@ -826,6 +844,7 @@ bd_bestslice(struct open_disk *od) return (prefslice); } +#ifdef LOADER_GPT_SUPPORT static int bd_open_gpt(struct open_disk *od, struct i386_devdesc *dev) { @@ -1003,6 +1022,7 @@ bd_best_gptpart(struct open_disk *od) } return (prefpart); } +#endif static int bd_close(struct open_file *f) @@ -1022,8 +1042,10 @@ bd_closedisk(struct open_disk *od) if (od->od_flags & BD_FLOPPY) delay(3000000); #endif +#ifdef LOADER_GPT_SUPPORT if (od->od_flags & BD_GPTOK) free(od->od_partitions); +#endif free(od); } diff --git a/sys/boot/i386/libi386/devicename.c b/sys/boot/i386/libi386/devicename.c index 79a562b..d6f3ac1 100644 --- a/sys/boot/i386/libi386/devicename.c +++ b/sys/boot/i386/libi386/devicename.c @@ -120,6 +120,7 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) err = EUNIT; goto fail; } +#ifdef LOADER_GPT_SUPPORT if (*cp == 'p') { /* got a GPT partition */ np = cp + 1; slice = strtol(np, &cp, 10); @@ -133,6 +134,7 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) } partition = 0xff; } else { +#endif if (*cp == 's') { /* got a slice number */ np = cp + 1; slice = strtol(np, &cp, 10); @@ -149,7 +151,9 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) } cp++; } +#ifdef LOADER_GPT_SUPPORT } +#endif } else { cp = np; } @@ -227,14 +231,18 @@ i386_fmtdev(void *vdev) case DEVT_DISK: cp = buf; cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit); +#ifdef LOADER_GPT_SUPPORT if (dev->d_kind.biosdisk.partition == 0xff) { cp += sprintf(cp, "p%d", dev->d_kind.biosdisk.slice); } else { +#endif if (dev->d_kind.biosdisk.slice > 0) cp += sprintf(cp, "s%d", dev->d_kind.biosdisk.slice); if (dev->d_kind.biosdisk.partition >= 0) cp += sprintf(cp, "%c", dev->d_kind.biosdisk.partition + 'a'); +#ifdef LOADER_GPT_SUPPORT } +#endif strcat(cp, ":"); break; diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile index cd3c951..8f3480a 100644 --- a/sys/boot/i386/loader/Makefile +++ b/sys/boot/i386/loader/Makefile @@ -51,6 +51,9 @@ CFLAGS+= -DLOADER_BZIP2_SUPPORT .if !defined(LOADER_NO_GZIP_SUPPORT) CFLAGS+= -DLOADER_GZIP_SUPPORT .endif +.if !defined(LOADER_NO_GPT_SUPPORT) +CFLAGS+= -DLOADER_GPT_SUPPORT +.endif # Always add MI sources .PATH: ${.CURDIR}/../../common diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index cac28ae..701dd3a 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -102,7 +102,7 @@ main(void) */ bios_getmem(); -#if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || defined(LOADER_ZFS_SUPPORT) +#if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || defined(LOADER_GPT_SUPPORT) || defined(LOADER_ZFS_SUPPORT) heap_top = PTOV(memtop_copyin); memtop_copyin -= 0x300000; heap_bottom = PTOV(memtop_copyin); |