Allow each drive type to describe itself on the boot menu.
This fixes a bug where driveid was used in place of ataid in the boot
menu.
Also, expand descriptions for each drive type.
Don't overload the IPL type for BCVs - instead introduce new types.
#include "cmos.h" // inb_cmos
#include "pic.h" // enable_hwirq
#include "biosvar.h" // GET_EBDA
-#include "pci.h" // pci_find_class
+#include "pci.h" // foreachpci
#include "pci_ids.h" // PCI_CLASS_STORAGE_OTHER
#include "pci_regs.h" // PCI_INTERRUPT_LINE
#include "boot.h" // add_bcv_hd
// Common flags.
SET_GLOBAL(Drives.drives[driveid].removable, (buffer[0] & 0x80) ? 1 : 0);
+ SET_GLOBAL(Drives.drives[driveid].cntl_info, extract_version(buffer));
+}
+
+void
+describe_atapi(int driveid)
+{
+ u8 ataid = Drives.drives[driveid].cntl_id;
+ u8 channel = ataid / 2;
+ u8 slave = ataid % 2;
+ u8 version = Drives.drives[driveid].cntl_info;
+ int iscd = Drives.drives[driveid].floppy_type;
+ printf("ata%d-%d: %s ATAPI-%d %s", channel, slave
+ , Drives.drives[driveid].model, version
+ , (iscd ? "CD-Rom/DVD-Rom" : "Device"));
}
static int
SET_GLOBAL(Drives.drives[driveid].blksize, CDROM_SECTOR_SIZE);
SET_GLOBAL(Drives.drives[driveid].sectors, (u64)-1);
u8 iscd = ((buffer[0] >> 8) & 0x1f) == 0x05;
-
- // Report drive info to user.
- u8 ataid = GET_GLOBAL(Drives.drives[driveid].cntl_id);
- u8 channel = ataid / 2;
- u8 slave = ataid % 2;
- printf("ata%d-%d: %s ATAPI-%d %s\n", channel, slave
- , Drives.drives[driveid].model, extract_version(buffer)
- , (iscd ? "CD-Rom/DVD-Rom" : "Device"));
+ SET_GLOBAL(Drives.drives[driveid].floppy_type, iscd);
// fill cdidmap
if (iscd)
return 0;
}
+void
+describe_ata(int driveid)
+{
+ u8 ataid = Drives.drives[driveid].cntl_id;
+ u8 channel = ataid / 2;
+ u8 slave = ataid % 2;
+ u64 sectors = Drives.drives[driveid].sectors;
+ u8 version = Drives.drives[driveid].cntl_info;
+ char *model = Drives.drives[driveid].model;
+ printf("ata%d-%d: %s ATA-%d Hard-Disk", channel, slave, model, version);
+ u64 sizeinmb = sectors >> 11;
+ if (sizeinmb < (1 << 16))
+ printf(" (%u MiBytes)", (u32)sizeinmb);
+ else
+ printf(" (%u GiBytes)", (u32)(sizeinmb >> 10));
+}
+
static int
init_drive_ata(int driveid, u16 *buffer)
{
// Setup disk geometry translation.
setup_translation(driveid);
- // Report drive info to user.
- u8 ataid = GET_GLOBAL(Drives.drives[driveid].cntl_id);
- u8 channel = ataid / 2;
- u8 slave = ataid % 2;
- char *model = Drives.drives[driveid].model;
- printf("ata%d-%d: %s ATA-%d Hard-Disk ", channel, slave, model
- , extract_version(buffer));
- u64 sizeinmb = sectors >> 11;
- if (sizeinmb < (1 << 16))
- printf("(%u MiBytes)\n", (u32)sizeinmb);
- else
- printf("(%u GiBytes)\n", (u32)(sizeinmb >> 10));
-
// Register with bcv system.
- add_bcv_hd(driveid, model);
+ add_bcv_internal(driveid);
return 0;
}
// check for ATAPI
u16 buffer[256];
int ret = init_drive_atapi(driveid, buffer);
- if (!ret) {
- // Found an ATAPI drive.
- } else {
+ if (ret) {
+ // Didn't find an ATAPI drive - look for ATA drive.
u8 st = inb(iobase1+ATA_CB_STAT);
if (!st)
// Status not set - can't be a valid drive.
}
SET_GLOBAL(Drives.drivecount, driveid+1);
+ // Report drive info to user.
+ describe_drive(driveid);
+ printf("\n");
+
u16 resetresult = buffer[93];
dprintf(6, "ata_detect resetresult=%04x\n", resetresult);
if (!slave && (resetresult & 0xdf61) == 0x4041)
void ata_setup();
int process_ata_op(struct disk_op_s *op);
int process_atapi_op(struct disk_op_s *op);
+void describe_ata(int driveid);
+void describe_atapi(int driveid);
// Global defines -- ATA register and register bits.
// command block & control block regs
}
}
+// Show a one line description (without trailing newline) of a drive.
+void
+describe_drive(int driveid)
+{
+ ASSERT32();
+ u8 type = GET_GLOBAL(Drives.drives[driveid].type);
+ switch (type) {
+ case DTYPE_FLOPPY:
+ describe_floppy(driveid);
+ break;
+ case DTYPE_ATA:
+ describe_ata(driveid);
+ break;
+ case DTYPE_ATAPI:
+ describe_atapi(driveid);
+ break;
+ case DTYPE_RAMDISK:
+ describe_ramdisk(driveid);
+ break;
+ default:
+ printf("Unknown");
+ break;
+ }
+}
+
/****************************************************************
* 16bit calling interface
return;
struct ipl_entry_s *ie = &IPL.bcv[IPL.bcvcount++];
- ie->type = IPL_TYPE_BEV;
+ ie->type = BCV_TYPE_EXTERNAL;
ie->vector = (seg << 16) | ip;
const char *d = "Legacy option rom";
if (desc)
ie->description = d;
}
-// Add a bcv entry for an ata harddrive
+// Add a bcv entry for an internal harddrive
void
-add_bcv_hd(int driveid, const char *desc)
+add_bcv_internal(int driveid)
{
if (! CONFIG_BOOT)
return;
return;
struct ipl_entry_s *ie = &IPL.bcv[IPL.bcvcount++];
- ie->type = IPL_TYPE_HARDDISK;
+ ie->type = BCV_TYPE_INTERNAL;
ie->vector = driveid;
- ie->description = desc;
+ ie->description = "";
}
{
int i;
for (i = 0; i < Drives.floppycount; i++) {
- printf("%d. floppy %d\n", menupos + i, i+1);
+ int driveid = Drives.idmap[EXTTYPE_FLOPPY][i];
+ printf("%d. Floppy [", menupos + i);
+ describe_drive(driveid);
+ printf("]\n");
}
return Drives.floppycount;
}
for (i = 0; i < IPL.bcvcount; i++) {
struct ipl_entry_s *ie = &IPL.bcv[i];
switch (ie->type) {
- case IPL_TYPE_HARDDISK:
- printf("%d. ata%d-%d %s\n", menupos + i
- , ie->vector / 2, ie->vector % 2, ie->description);
+ case BCV_TYPE_INTERNAL:
+ printf("%d. ", menupos + i);
+ describe_drive(ie->vector);
+ printf("\n");
break;
default:
menu_show_default(ie, menupos+i);
int i;
for (i = 0; i < Drives.cdcount; i++) {
int driveid = Drives.idmap[EXTTYPE_CD][i];
- printf("%d. CD-Rom [ata%d-%d %s]\n", menupos + i
- , driveid / 2, driveid % 2, Drives.drives[driveid].model);
+ printf("%d. CD-Rom [", menupos + i);
+ describe_drive(driveid);
+ printf("]\n");
}
return Drives.cdcount;
}
run_bcv(struct ipl_entry_s *ie)
{
switch (ie->type) {
- case IPL_TYPE_HARDDISK:
+ case BCV_TYPE_INTERNAL:
map_hd_drive(ie->vector);
break;
- case IPL_TYPE_BEV:
+ case BCV_TYPE_EXTERNAL:
call_bcv(ie->vector >> 16, ie->vector & 0xffff);
break;
}
#define IPL_TYPE_CBFS 0x20
#define IPL_TYPE_BEV 0x80
+#define BCV_TYPE_EXTERNAL 0x80
+#define BCV_TYPE_INTERNAL 0x02
+
/****************************************************************
* Function defs
void boot_setup();
void add_bev(u16 seg, u16 bev, u16 desc);
void add_bcv(u16 seg, u16 ip, u16 desc);
-void add_bcv_hd(int driveid, const char *desc);
+void add_bcv_internal(int driveid);
void boot_prep();
#endif // __BOOT_H
return NULL;
}
+// Find next file with the given filename prefix.
struct cbfs_file *
cbfs_findprefix(const char *prefix, struct cbfs_file *last)
{
u8 type; // Detected type of drive (ata/atapi/none)
u8 removable; // Removable device flag
u16 blksize; // block size
- int cntl_id;
+ u32 cntl_id;
+ u32 cntl_info;
u8 floppy_type; // Type of floppy (only for floppy drives).
char model[41];
void map_floppy_drive(int driveid);
void map_hd_drive(int driveid);
void map_cd_drive(int driveid);
+void describe_drive(int driveid);
int send_disk_op(struct disk_op_s *op);
void drive_setup();
// floppy.c
extern struct floppy_ext_dbt_s diskette_param_table2;
void floppy_setup();
-void addFloppy(int floppyid, int ftype, int driver);
+int addFloppy(int floppyid, int ftype, int driver);
+void describe_floppy(int driveid);
int find_floppy_type(u32 size);
int process_floppy_op(struct disk_op_s *op);
void floppy_tick();
int cdrom_boot(int cdid);
// ramdisk.c
+void describe_ramdisk(int driveid);
void ramdisk_setup();
int process_ramdisk_op(struct disk_op_s *op);
{ {2, 40, 8}, 0x00, 0x27},
};
-void
+int
addFloppy(int floppyid, int ftype, int driver)
{
if (ftype <= 0 || ftype >= ARRAY_SIZE(FloppyInfo)) {
dprintf(1, "Bad floppy type %d\n", ftype);
- return;
+ return -1;
}
int driveid = Drives.drivecount;
if (driveid >= ARRAY_SIZE(Drives.drives))
- return;
+ return -1;
Drives.drivecount++;
memset(&Drives.drives[driveid], 0, sizeof(Drives.drives[0]));
Drives.drives[driveid].cntl_id = floppyid;
, sizeof(FloppyInfo[ftype].chs));
map_floppy_drive(driveid);
+ return driveid;
+}
+
+void
+describe_floppy(int driveid)
+{
+ printf("drive %c", 'A' + Drives.drives[driveid].cntl_id);
}
void
#include "farptr.h" // FLATPTR_TO_SEG
#include "config.h" // CONFIG_*
#include "util.h" // dprintf
-#include "pci.h" // pci_find_class
+#include "pci.h" // foreachpci
#include "pci_regs.h" // PCI_ROM_ADDRESS
#include "pci_ids.h" // PCI_CLASS_DISPLAY_VGA
#include "boot.h" // IPL
#define RAMDISK_SECTOR_SIZE 512
+void
+describe_ramdisk(int driveid)
+{
+ printf("%s", Drives.drives[driveid].model);
+}
+
void
ramdisk_setup()
{
// Setup driver.
dprintf(1, "Mapping CBFS floppy %s to addr %p\n", cbfs_filename(file), pos);
- addFloppy((u32)pos, ftype, DTYPE_RAMDISK);
+ int driveid = addFloppy((u32)pos, ftype, DTYPE_RAMDISK);
+ if (driveid >= 0)
+ strtcpy(Drives.drives[driveid].model, cbfs_filename(file)
+ , ARRAY_SIZE(Drives.drives[driveid].model));
}
static int