- Allow support for MBR boot loaders that are longer than one sector. As

with fdisk, ensure that they are a multiple of the sector size in length.
- Axe all the 1024 cylinder checks as they are no longer relevant with the
  fixed bootstrap.
This commit is contained in:
John Baldwin 2000-07-12 18:05:18 +00:00
parent 67b6e9dd8b
commit be0fdc4646
6 changed files with 16 additions and 62 deletions

View File

@ -25,9 +25,6 @@ Set_Bios_Geom(struct disk *disk, u_long cyl, u_long hd, u_long sect)
disk->bios_cyl = cyl;
disk->bios_hd = hd;
disk->bios_sect = sect;
#ifndef PC98
Bios_Limit_Chunk(disk->chunks,1024*hd*sect);
#endif
}
/* XXX - parameters should change to fit for PC-98, but I'm not sure */

View File

@ -322,9 +322,6 @@ ShowChunkFlags(struct chunk *c)
if (c->flags & CHUNK_BSD_COMPAT) ret[i++] = 'C';
if (c->flags & CHUNK_ACTIVE) ret[i++] = 'A';
if (c->flags & CHUNK_ALIGN) ret[i++] = '=';
#ifndef PC98
if (c->flags & CHUNK_PAST_1024) ret[i++] = '>';
#endif
if (c->flags & CHUNK_IS_ROOT) ret[i++] = 'R';
ret[i++] = '\0';
return ret;
@ -359,22 +356,6 @@ Debug_Chunk(struct chunk *c1)
Print_Chunk(c1,2);
}
#ifndef PC98
void
Bios_Limit_Chunk(struct chunk *c1, u_long limit)
{
if (c1->part)
Bios_Limit_Chunk(c1->part,limit);
if (c1->next)
Bios_Limit_Chunk(c1->next,limit);
if (c1->end >= limit) {
c1->flags |= CHUNK_PAST_1024;
} else {
c1->flags &= ~CHUNK_PAST_1024;
}
}
#endif
int
Delete_Chunk(struct disk *d, struct chunk *c)
{

View File

@ -361,9 +361,6 @@ Int_Open_Disk(const char *name, u_long size)
#endif
close(fd);
Fixup_Names(d);
#ifndef PC98
Bios_Limit_Chunk(d->chunks,1024*d->bios_hd*d->bios_sect);
#endif
return d;
}
@ -412,8 +409,8 @@ Clone_Disk(struct disk *d)
d2->name = strdup(d2->name);
d2->chunks = Clone_Chunk(d2->chunks);
if(d2->bootmgr) {
d2->bootmgr = malloc(DOSPARTOFF);
memcpy(d2->bootmgr,d->bootmgr,DOSPARTOFF);
d2->bootmgr = malloc(d2->bootmgr_size);
memcpy(d2->bootmgr,d->bootmgr,d2->bootmgr_size);
}
#if defined(__i386__)
if(d2->boot1) {
@ -502,17 +499,21 @@ Disk_Names()
}
void
Set_Boot_Mgr(struct disk *d, const u_char *b)
Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
{
#ifndef PC98
/* XXX - assumes sector size of 512 */
if (s % 512 != 0)
return;
if (d->bootmgr)
free(d->bootmgr);
if (!b) {
d->bootmgr = 0;
d->bootmgr = NULL;
} else {
d->bootmgr = malloc(DOSPARTOFF);
d->bootmgr_size = s;
d->bootmgr = malloc(s);
if(!d->bootmgr) err(1,"malloc failed");
memcpy(d->bootmgr,b,DOSPARTOFF);
memcpy(d->bootmgr,b,s);
}
#endif
}

View File

@ -32,6 +32,7 @@ struct disk {
u_long bios_hd;
u_long bios_sect;
u_char *bootmgr;
size_t bootmgr_size;
u_char *boot1;
#if defined(__i386__) /* the alpha only has one boot program */
u_char *boot2;
@ -57,10 +58,6 @@ struct chunk {
chunk_e type;
int subtype;
u_long flags;
# define CHUNK_PAST_1024 1
/* this chunk cannot be booted from because it
* extends past cylinder 1024
*/
# define CHUNK_BSD_COMPAT 2
/* this chunk is in the BSD-compatibility, and has a
* short name too, ie wd0s4f -> wd0f
@ -167,7 +164,7 @@ Disk_Names();
*/
void
Set_Boot_Mgr(struct disk *d, const u_char *bootmgr);
Set_Boot_Mgr(struct disk *d, const u_char *bootmgr, const size_t bootmgr_size);
/* Use this boot-manager on this disk. Gets written when Write_Disk()
* is called
*/
@ -252,7 +249,6 @@ int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long, c
#else
int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long);
#endif
void Bios_Limit_Chunk(struct chunk *, u_long);
void * read_block(int, daddr_t);
void write_block(int fd, daddr_t block, void *foo);
struct disklabel * read_disklabel(int, daddr_t);

View File

@ -200,8 +200,6 @@ Rule_003(struct disk *d, struct chunk *c, char *msg)
* Rule#4:
* Max seven 'part' as children of 'freebsd'
* Max one CHUNK_IS_ROOT child per 'freebsd'
* If Bad144, space for table must exist.
* If Bad144 & root, bad144 table must be inside 1024
*/
void
Rule_004(struct disk *d, struct chunk *c, char *msg)
@ -215,14 +213,8 @@ Rule_004(struct disk *d, struct chunk *c, char *msg)
for (c1=c->part; c1; c1=c1->next) {
if (c1->type != part)
continue;
if (c1->flags & CHUNK_IS_ROOT) {
if (c1->flags & CHUNK_IS_ROOT)
k++;
#ifndef PC98
if (c1->flags & CHUNK_PAST_1024)
sprintf(msg+strlen(msg),
"Root filesystem extends past cylinder 1024, and cannot be booted from\n");
#endif
}
i++;
}
if (i > 7) {
@ -247,13 +239,6 @@ Check_Chunk(struct disk *d, struct chunk *c, char *msg)
Check_Chunk(d,c->part,msg);
if (c->next)
Check_Chunk(d,c->next,msg);
#ifndef PC98
if (c->end >= 1024*d->bios_hd*d->bios_sect)
c->flags |= CHUNK_PAST_1024;
else
c->flags &= ~CHUNK_PAST_1024;
#endif
}
char *
@ -276,15 +261,6 @@ ChunkCanBeRoot(struct chunk *c)
char msg[BUFSIZ];
*msg = '\0';
#ifndef PC98
if (c->flags & CHUNK_PAST_1024) {
strcat(msg,
"The root partition must end before cylinder 1024 seen from\n");
strcat(msg,
"the BIOS' point of view, or it cannot be booted from.\n");
return strdup(msg);
}
#endif
for (c1=d->chunks->part;;) {
for (; c1; c1=c1->next)
if (c1->offset <= c->offset && c1->end >= c->end)

View File

@ -354,6 +354,9 @@ Write_Disk(struct disk *d1)
mbr[512-2] = 0x55;
mbr[512-1] = 0xaa;
write_block(fd,WHERE(0,d1),mbr);
if (d1->bootmgr && d1->bootmgr_size > 512)
for(i = 1; i * 512 <= d1->bootmgr_size; i++)
write_block(fd,WHERE(i,d1),&d1->bootmgr[i * 512]);
#endif
#endif