mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-30 16:51:41 +00:00
Teach libdisk about alpha boot blocks.
This commit is contained in:
parent
a20d77550a
commit
5b4c313702
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40000
@ -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 \
|
||||
|
@ -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 *
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user