diff options
Diffstat (limited to 'lib/libdisk/write_disk.c')
-rw-r--r-- | lib/libdisk/write_disk.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c index 5ac0ea7..3e8ad8a 100644 --- a/lib/libdisk/write_disk.c +++ b/lib/libdisk/write_disk.c @@ -29,7 +29,11 @@ #define DEF_RPM 3600 #define DEF_INTERLEAVE 1 +#ifdef PC98 +#define WHERE(offset,disk) (offset) +#else #define WHERE(offset,disk) (disk->flags & DISK_ON_TRACK ? offset + 63 : offset) +#endif int Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) { @@ -103,11 +107,17 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1) new->name[0] == 'o' ? DTYPE_SCSI : DTYPE_ESDI; dl->d_partitions[RAW_PART].p_size = c1->size; dl->d_partitions[RAW_PART].p_offset = c1->offset; +#ifdef PC98 + dl->d_rpm = 3600; + dl->d_interleave = 1; +#endif +#ifndef PC98 if(new->flags & DISK_ON_TRACK) for(i=0;i<MAXPARTITIONS;i++) if (dl->d_partitions[i].p_size) dl->d_partitions[i].p_offset += 63; +#endif dl->d_magic = DISKMAGIC; dl->d_magic2 = DISKMAGIC; dl->d_checksum = dkcksum(dl); @@ -162,13 +172,26 @@ Write_Disk(struct disk *d1) char device[64]; u_char *mbr; struct dos_partition *dp,work[NDOSPART]; +#ifdef PC98 + int s[7]; + int PC98_EntireDisk = 0; +#else int s[4]; +#endif int one = 1; int zero = 0; strcpy(device,"/dev/r"); strcat(device,d1->name); +#ifdef PC98 + /* XXX - for entire FreeBSD(98) */ + for (c1 = d1->chunks->part; c1; c1 = c1->next) { + if ((c1->type == freebsd) || (c1->offset == 0)) + device[9] = 0; + } +#endif + fd = open(device,O_RDWR); if (fd < 0) { #ifdef DEBUG @@ -179,7 +202,11 @@ Write_Disk(struct disk *d1) ioctl(fd, DIOCWLABEL, &one); memset(s,0,sizeof s); +#ifdef PC98 + mbr = read_block(fd,WHERE(1,d1)); +#else mbr = read_block(fd,WHERE(0,d1)); +#endif dp = (struct dos_partition*) (mbr + DOSPARTOFF); memcpy(work,dp,sizeof work); dp = work; @@ -190,20 +217,37 @@ Write_Disk(struct disk *d1) #ifndef __alpha__ j = c1->name[4] - '1'; j = c1->name[strlen(d1->name) + 1] - '1'; +#ifdef PC98 + if (j < 0 || j > 7) +#else if (j < 0 || j > 3) +#endif continue; s[j]++; #endif +#ifndef PC98 if (c1->type == extended) ret += Write_Extended(fd, d1,old,c1); +#endif if (c1->type == freebsd) ret += Write_FreeBSD(fd, d1,old,c1); #ifndef __alpha__ +#ifndef PC98 Write_Int32(&dp[j].dp_start, c1->offset); Write_Int32(&dp[j].dp_size, c1->size); +#endif i = c1->offset; +#ifdef PC98 + dp[j].dp_ssect = dp[j].dp_ipl_sct = i % d1->bios_sect; + i -= dp[j].dp_ssect; + i /= d1->bios_sect; + dp[j].dp_shd = dp[j].dp_ipl_head = i % d1->bios_hd; + i -= dp[j].dp_shd; + i /= d1->bios_hd; + dp[j].dp_scyl = dp[j].dp_ipl_cyl = i; +#else if (i >= 1024*d1->bios_sect*d1->bios_hd) { dp[j].dp_ssect = 0xff; dp[j].dp_shd = 0xff; @@ -219,6 +263,7 @@ Write_Disk(struct disk *d1) i -= dp[j].dp_scyl; dp[j].dp_ssect |= i >> 2; } +#endif #ifdef DEBUG printf("S:%lu = (%x/%x/%x)", @@ -226,6 +271,20 @@ Write_Disk(struct disk *d1) #endif i = c1->end; +#ifdef PC98 +#if 1 + dp[j].dp_esect = dp[j].dp_ehd = 0; + dp[j].dp_ecyl = i / (d1->bios_sect * d1->bios_hd); +#else + dp[j].dp_esect = i % d1->bios_sect; + i -= dp[j].dp_esect; + i /= d1->bios_sect; + dp[j].dp_ehd = i % d1->bios_hd; + i -= dp[j].dp_ehd; + i /= d1->bios_hd; + dp[j].dp_ecyl = i; +#endif +#else dp[j].dp_esect = i % d1->bios_sect; i -= dp[j].dp_esect++; i /= d1->bios_sect; @@ -236,32 +295,57 @@ Write_Disk(struct disk *d1) dp[j].dp_ecyl = i; i -= dp[j].dp_ecyl; dp[j].dp_esect |= i >> 2; +#endif #ifdef DEBUG printf(" E:%lu = (%x/%x/%x)\n", c1->end,dp[j].dp_ecyl,dp[j].dp_ehd,dp[j].dp_esect); #endif +#ifdef PC98 + dp[j].dp_mid = c1->subtype & 0xff; + dp[j].dp_sid = c1->subtype >> 8; + if (c1->flags & CHUNK_ACTIVE) + dp[j].dp_mid |= 0x80; + + strncpy(dp[j].dp_name, c1->sname, 16); +#else dp[j].dp_typ = c1->subtype; if (c1->flags & CHUNK_ACTIVE) dp[j].dp_flag = 0x80; else dp[j].dp_flag = 0; #endif +#endif } #ifndef __alpha__ j = 0; for(i=0;i<NDOSPART;i++) { if (!s[i]) memset(dp+i,0,sizeof *dp); +#ifndef PC98 if (dp[i].dp_flag) j++; +#endif } +#ifndef PC98 if (!j) for(i=0;i<NDOSPART;i++) if (dp[i].dp_typ == 0xa5) dp[i].dp_flag = 0x80; +#endif +#ifdef PC98 + mbr = read_block(fd,WHERE(1,d1)); + memcpy(mbr+DOSPARTOFF,dp,sizeof *dp * NDOSPART); + /* XXX - for entire FreeBSD(98) */ + for (c1 = d1->chunks->part; c1; c1 = c1->next) + if (((c1->type == freebsd) || (c1->type == fat)) + && (c1->offset == 0)) + PC98_EntireDisk = 1; + if (PC98_EntireDisk == 0) + write_block(fd,WHERE(1,d1),mbr); +#else mbr = read_block(fd,WHERE(0,d1)); if (d1->bootmgr) memcpy(mbr,d1->bootmgr,DOSPARTOFF); @@ -270,6 +354,7 @@ Write_Disk(struct disk *d1) mbr[512-1] = 0xaa; write_block(fd,WHERE(0,d1),mbr); #endif +#endif i = 1; i = ioctl(fd,DIOCSYNCSLICEINFO,&i); |