summaryrefslogtreecommitdiffstats
path: root/lib/libdisk
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2000-08-12 14:20:31 +0000
committernyan <nyan@FreeBSD.org>2000-08-12 14:20:31 +0000
commit784618782ee6136ae55c487d6cd37057e7713394 (patch)
tree595442ab24ee1b8cd5cde2487f8a5d440ec1864d /lib/libdisk
parent0f9d7e675d007edbbc28ad5299e578b24acae95f (diff)
downloadFreeBSD-src-784618782ee6136ae55c487d6cd37057e7713394.zip
FreeBSD-src-784618782ee6136ae55c487d6cd37057e7713394.tar.gz
- Added support for installing boot0 and boot0.5 for PC-98.
- Cosmetic changes.
Diffstat (limited to 'lib/libdisk')
-rw-r--r--lib/libdisk/disk.c57
-rw-r--r--lib/libdisk/libdisk.h13
-rw-r--r--lib/libdisk/write_disk.c7
3 files changed, 75 insertions, 2 deletions
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index 9a35d45..83617ad 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -378,7 +378,10 @@ 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__)
+#if defined(PC98)
+ printf(" boot1=%p, boot2=%p, bootipl=%p, bootmenu=%p\n",
+ d->boot1,d->boot2,d->bootipl,d->bootmenu);
+#elif defined(__i386__)
printf(" boot1=%p, boot2=%p, bootmgr=%p\n",
d->boot1,d->boot2,d->bootmgr);
#elif defined(__alpha__)
@@ -393,7 +396,12 @@ Free_Disk(struct disk *d)
{
if(d->chunks) Free_Chunk(d->chunks);
if(d->name) free(d->name);
+#ifdef PC98
+ if(d->bootipl) free(d->bootipl);
+ if(d->bootmenu) free(d->bootmenu);
+#else
if(d->bootmgr) free(d->bootmgr);
+#endif
if(d->boot1) free(d->boot1);
#if defined(__i386__)
if(d->boot2) free(d->boot2);
@@ -411,10 +419,21 @@ Clone_Disk(struct disk *d)
*d2 = *d;
d2->name = strdup(d2->name);
d2->chunks = Clone_Chunk(d2->chunks);
+#ifdef PC98
+ if(d2->bootipl) {
+ d2->bootipl = malloc(d2->bootipl_size);
+ memcpy(d2->bootipl,d->bootipl,d2->bootipl_size);
+ }
+ if(d2->bootmenu) {
+ d2->bootmenu = malloc(d2->bootmenu_size);
+ memcpy(d2->bootmenu,d->bootmenu,d2->bootmenu_size);
+ }
+#else
if(d2->bootmgr) {
d2->bootmgr = malloc(d2->bootmgr_size);
memcpy(d2->bootmgr,d->bootmgr,d2->bootmgr_size);
}
+#endif
#if defined(__i386__)
if(d2->boot1) {
d2->boot1 = malloc(512);
@@ -505,10 +524,44 @@ Disk_Names()
return disks;
}
+#ifdef PC98
+void
+Set_Boot_Mgr(struct disk *d, const u_char *bootipl, const size_t bootipl_size,
+ const u_char *bootmenu, const size_t bootmenu_size)
+#else
void
Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
+#endif
{
-#ifndef PC98
+#ifdef PC98
+ /* XXX - assumes sector size of 512 */
+ if (bootipl_size % 512 != 0)
+ return;
+ if (d->bootipl)
+ free(d->bootipl);
+ if (!bootipl) {
+ d->bootipl = NULL;
+ } else {
+ d->bootipl_size = bootipl_size;
+ d->bootipl = malloc(bootipl_size);
+ if(!d->bootipl) err(1,"malloc failed");
+ memcpy(d->bootipl,bootipl,bootipl_size);
+ }
+
+ /* XXX - assumes sector size of 512 */
+ if (bootmenu_size % 512 != 0)
+ return;
+ if (d->bootmenu)
+ free(d->bootmenu);
+ if (!bootmenu) {
+ d->bootmenu = NULL;
+ } else {
+ d->bootmenu_size = bootmenu_size;
+ d->bootmenu = malloc(bootmenu_size);
+ if(!d->bootmenu) err(1,"malloc failed");
+ memcpy(d->bootmenu,bootmenu,bootmenu_size);
+ }
+#else
/* XXX - assumes sector size of 512 */
if (s % 512 != 0)
return;
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index bfc3c72..34646dd 100644
--- a/lib/libdisk/libdisk.h
+++ b/lib/libdisk/libdisk.h
@@ -31,8 +31,15 @@ struct disk {
u_long bios_cyl;
u_long bios_hd;
u_long bios_sect;
+#ifdef PC98
+ u_char *bootipl;
+ size_t bootipl_size;
+ u_char *bootmenu;
+ size_t bootmenu_size;
+#else
u_char *bootmgr;
size_t bootmgr_size;
+#endif
u_char *boot1;
#if defined(__i386__) /* the alpha only has one boot program */
u_char *boot2;
@@ -163,8 +170,14 @@ Disk_Names();
* each pointer, as well as the array by hand
*/
+#ifdef PC98
+void
+Set_Boot_Mgr(struct disk *d, const u_char *bootipl, const size_t bootipl_size,
+ const u_char *bootmenu, const size_t bootmenu_size);
+#else
void
Set_Boot_Mgr(struct disk *d, const u_char *bootmgr, const size_t bootmgr_size);
+#endif
/* Use this boot-manager on this disk. Gets written when Write_Disk()
* is called
*/
diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c
index 83c17b1..54025b2 100644
--- a/lib/libdisk/write_disk.c
+++ b/lib/libdisk/write_disk.c
@@ -339,6 +339,9 @@ Write_Disk(struct disk *d1)
#endif
#ifdef PC98
+ if (d1->bootipl)
+ write_block(fd,WHERE(0,d1),d1->bootipl);
+
mbr = read_block(fd,WHERE(1,d1));
memcpy(mbr+DOSPARTOFF,dp,sizeof *dp * NDOSPART);
/* XXX - for entire FreeBSD(98) */
@@ -348,6 +351,10 @@ Write_Disk(struct disk *d1)
PC98_EntireDisk = 1;
if (PC98_EntireDisk == 0)
write_block(fd,WHERE(1,d1),mbr);
+
+ if (d1->bootmenu)
+ for (i = 0; i * 512 < d1->bootmenu_size; i++)
+ write_block(fd,WHERE(2+i,d1),&d1->bootmenu[i * 512]);
#else
mbr = read_block(fd,WHERE(0,d1));
if (d1->bootmgr)
OpenPOWER on IntegriCloud