diff options
author | dfr <dfr@FreeBSD.org> | 1998-10-06 11:57:08 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1998-10-06 11:57:08 +0000 |
commit | b0393b65d51b5998e5ba7bab905641e9f3cea870 (patch) | |
tree | 85dca493a4452fc1877a288d27920dcbae28b54b /lib/libdisk | |
parent | 0d42654efcd0ffe1ba718aa12adceba0cf2ca19b (diff) | |
download | FreeBSD-src-b0393b65d51b5998e5ba7bab905641e9f3cea870.zip FreeBSD-src-b0393b65d51b5998e5ba7bab905641e9f3cea870.tar.gz |
Teach libdisk about alpha boot blocks.
Diffstat (limited to 'lib/libdisk')
-rw-r--r-- | lib/libdisk/Makefile | 9 | ||||
-rw-r--r-- | lib/libdisk/disk.c | 23 | ||||
-rw-r--r-- | lib/libdisk/libdisk.h | 4 | ||||
-rw-r--r-- | lib/libdisk/write_disk.c | 19 |
4 files changed, 51 insertions, 4 deletions
diff --git a/lib/libdisk/Makefile b/lib/libdisk/Makefile index 05919d5..1b1200d 100644 --- a/lib/libdisk/Makefile +++ b/lib/libdisk/Makefile @@ -1,4 +1,4 @@ -# $Id$ +# $Id: Makefile,v 1.20 1997/02/22 15:06:25 peter Exp $ LIB= disk SRCS= blocks.c disklabel.c dkcksum.c chunk.c disk.c change.c \ @@ -44,12 +44,19 @@ MLINKS+= libdisk.3 Open_Disk.3 \ BOOTS=/usr/mdec +.if ${MACHINE_ARCH} == "i386" data.c: ${.CURDIR}/libdisk.h ${BOOTS}/boot1 ${BOOTS}/boot2 file2c 'const unsigned char boot1[] = {' '};' \ < ${BOOTS}/boot1 > tmp.c file2c 'const unsigned char boot2[] = {' '};' \ < ${BOOTS}/boot2 >> tmp.c mv -f tmp.c data.c +.elif ${MACHINE_ARCH} == "alpha" +data.c: ${.CURDIR}/libdisk.h ${BOOTS}/boot1 + file2c 'const unsigned char boot1[] = {' '};' \ + < ${BOOTS}/boot1 > tmp.c + mv -f tmp.c data.c +.endif beforeinstall: ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/libdisk.h \ diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c index f95f1c1..f5c1999 100644 --- a/lib/libdisk/disk.c +++ b/lib/libdisk/disk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: disk.c,v 1.36 1998/09/15 10:23:17 gibbs Exp $ + * $Id: disk.c,v 1.37 1998/09/30 21:40:51 jkh Exp $ * */ @@ -258,8 +258,13 @@ Debug_Disk(struct disk *d) printf(" bios_geom=%lu/%lu/%lu = %lu\n", d->bios_cyl,d->bios_hd,d->bios_sect, d->bios_cyl*d->bios_hd*d->bios_sect); +#if defined(__i386__) printf(" boot1=%p, boot2=%p, bootmgr=%p\n", d->boot1,d->boot2,d->bootmgr); +#elif defined(__alpha__) + printf(" boot1=%p, bootmgr=%p\n", + d->boot1,d->bootmgr); +#endif Debug_Chunk(d->chunks); } @@ -270,7 +275,9 @@ Free_Disk(struct disk *d) if(d->name) free(d->name); if(d->bootmgr) free(d->bootmgr); if(d->boot1) free(d->boot1); +#if defined(__i386__) if(d->boot2) free(d->boot2); +#endif free(d); } @@ -288,6 +295,7 @@ Clone_Disk(struct disk *d) d2->bootmgr = malloc(DOSPARTOFF); memcpy(d2->bootmgr,d->bootmgr,DOSPARTOFF); } +#if defined(__i386__) if(d2->boot1) { d2->boot1 = malloc(512); memcpy(d2->boot1,d->boot1,512); @@ -296,6 +304,12 @@ Clone_Disk(struct disk *d) d2->boot2 = malloc(512*15); memcpy(d2->boot2,d->boot2,512*15); } +#elif defined(__alpha__) + if(d2->boot1) { + d2->boot1 = malloc(512*15); + memcpy(d2->boot1,d->boot1,512*15); + } +#endif return d2; } @@ -362,6 +376,7 @@ Set_Boot_Mgr(struct disk *d, const u_char *b) void Set_Boot_Blocks(struct disk *d, const u_char *b1, const u_char *b2) { +#if defined(__i386__) if (d->boot1) free(d->boot1); d->boot1 = malloc(512); if(!d->boot1) err(1,"malloc failed"); @@ -370,6 +385,12 @@ Set_Boot_Blocks(struct disk *d, const u_char *b1, const u_char *b2) d->boot2 = malloc(15*512); if(!d->boot2) err(1,"malloc failed"); memcpy(d->boot2,b2,15*512); +#elif defined(__alpha__) + if (d->boot1) free(d->boot1); + d->boot1 = malloc(15*512); + if(!d->boot1) err(1,"malloc failed"); + memcpy(d->boot1,b1,15*512); +#endif } const char * diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h index cbf18e8..3ae62ca 100644 --- a/lib/libdisk/libdisk.h +++ b/lib/libdisk/libdisk.h @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * -* $Id: libdisk.h,v 1.27 1997/03/19 01:54:04 bde Exp $ +* $Id: libdisk.h,v 1.28 1998/01/20 11:03:15 bde Exp $ * */ @@ -33,7 +33,9 @@ struct disk { u_long bios_sect; u_char *bootmgr; u_char *boot1; +#if defined(__i386__) /* the alpha only has one boot program */ u_char *boot2; +#endif struct chunk *chunks; }; diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c index cf7e87a..6d3b2a7 100644 --- a/lib/libdisk/write_disk.c +++ b/lib/libdisk/write_disk.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: write_disk.c,v 1.21 1998/06/27 02:01:25 jdp Exp $ + * $Id: write_disk.c,v 1.22 1998/09/30 21:40:51 jkh Exp $ * */ @@ -38,17 +38,25 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) int i,j; void *p; u_char buf[BBSIZE]; +#ifdef __alpha__ + u_long *lp, sum; +#endif for(i=0;i<BBSIZE/512;i++) { p = read_block(fd,WHERE(i + c1->offset,new)); memcpy(buf+512*i,p,512); free(p); } +#if defined(__i386__) if(new->boot1) memcpy(buf,new->boot1,512); if(new->boot2) memcpy(buf+512,new->boot2,BBSIZE-512); +#elif defined(__alpha__) + if(new->boot1) + memcpy(buf+512,new->boot1,BBSIZE-512); +#endif dl = (struct disklabel *) (buf+512*LABELSECTOR+LABELOFFSET); memset(dl,0,sizeof *dl); @@ -100,6 +108,15 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) dl->d_magic2 = DISKMAGIC; dl->d_checksum = dkcksum(dl); +#ifdef __alpha__ + /* + * Generate the bootblock checksum for the SRM console. + */ + for (lp = (u_long *)buf, i = 0, sum = 0; i < 63; i++) + sum += lp[i]; + lp[63] = sum; +#endif + for(i=0;i<BBSIZE/512;i++) { write_block(fd,WHERE(i + c1->offset,new),buf+512*i); } |