Add a preliminary CD boot support to uboot for preparation of PR/54455.

Briefly tested on mame, but not enalbed yet.
This commit is contained in:
tsutsui 2024-05-09 15:11:11 +00:00
parent 9bda463035
commit 27f0c68149
7 changed files with 77 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.14 2022/12/11 07:39:30 tsutsui Exp $ */
/* $NetBSD: conf.c,v 1.15 2024/05/09 15:11:11 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -41,6 +41,7 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/nfs.h>
#include <lib/libsa/ufs.h>
#include <lib/libsa/cd9660.h>
#include <hp300/stand/common/conf.h>
#include <hp300/stand/common/rawfs.h>
@ -138,13 +139,16 @@ int npunit = __arraycount(punitsw);
* Filesystem configuration
*/
struct fs_ops file_system_rawfs[1] = { FS_OPS(rawfs) };
struct fs_ops file_system_ufs[NFSYS_UFS] = {
struct fs_ops file_system_ufs[NFSYS_FS] = {
FS_OPS(ffsv1),
#ifdef SUPPORT_UFS2
FS_OPS(ffsv2),
#endif
#ifdef SUPPORT_CD
FS_OPS(cd9660),
#endif
};
struct fs_ops file_system_nfs[1] = { FS_OPS(nfs) };
struct fs_ops file_system[NFSYS_UFS];
struct fs_ops file_system[NFSYS_FS];
int nfsys = 1; /* default value; should be overrieded */

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.h,v 1.3 2022/12/11 07:39:30 tsutsui Exp $ */
/* $NetBSD: conf.h,v 1.4 2024/05/09 15:11:11 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@ -53,10 +53,16 @@ int sdopen(struct open_file *, ...);
int sdclose(struct open_file *);
#endif
#ifdef SUPPORT_UFS2
#define NFSYS_UFS 2
#define NFSYS_UFS2 1
#else
#define NFSYS_UFS 1
#define NFSYS_UFS2 0
#endif
#ifdef SUPPORT_CD
#define NFSYS_CD9660 1
#else
#define NFSYS_CD9660 0
#endif
#define NFSYS_FS (1 + NFSYS_UFS2 + NFSYS_CD9660)
#ifdef SUPPORT_ETHERNET
extern struct netif_driver le_driver;
@ -72,5 +78,5 @@ extern struct punitsw punitsw[];
extern int npunit;
extern struct fs_ops file_system_rawfs[1];
extern struct fs_ops file_system_ufs[NFSYS_UFS];
extern struct fs_ops file_system_ufs[NFSYS_FS];
extern struct fs_ops file_system_nfs[1];

View File

@ -1,4 +1,4 @@
/* $NetBSD: devopen.c,v 1.14 2023/01/15 06:19:46 tsutsui Exp $ */
/* $NetBSD: devopen.c,v 1.15 2024/05/09 15:11:11 tsutsui Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@ -105,7 +105,7 @@ devlookup(const char *d, int len)
case 4: /* sd */
memcpy(file_system, file_system_ufs,
sizeof(file_system_ufs));
nfsys = NFSYS_UFS;
nfsys = NFSYS_FS;
break;
case 6: /* le */
@ -263,7 +263,7 @@ devopen(struct open_file *f, const char *fname, char **file)
case 4: /* sd */
memcpy(file_system, file_system_ufs,
sizeof(file_system_ufs));
nfsys = NFSYS_UFS;
nfsys = NFSYS_FS;
break;
case 6: /* le */

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi.c,v 1.12 2023/01/15 06:19:46 tsutsui Exp $ */
/* $NetBSD: scsi.c,v 1.13 2024/05/09 15:11:11 tsutsui Exp $ */
/*
* This is reported to fix some odd failures when disklabeling
@ -400,6 +400,19 @@ scsi_read_capacity(int ctlr, int slave, uint8_t *buf, unsigned int len)
DATA_IN_PHASE);
}
#ifdef SUPPORT_CD
int
scsi_inquiry(int ctlr, int slave, uint8_t *buf, unsigned int len)
{
struct scsi_softc *hs = &scsi_softc[ctlr];
static struct scsi_cdb6 cdb = { CMD_INQUIRY };
cdb.len = len;
return scsiicmd(hs, slave, (uint8_t *)&cdb, sizeof(cdb), buf, len,
DATA_IN_PHASE);
}
#endif
int
scsi_tt_read(int ctlr, int slave, uint8_t *buf, u_int len, daddr_t blk,
u_int nblk)

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsireg.h,v 1.5 2023/01/15 06:19:46 tsutsui Exp $ */
/* $NetBSD: scsireg.h,v 1.6 2024/05/09 15:11:11 tsutsui Exp $ */
/*
* Copyright (c) 1990, 1993
@ -274,6 +274,9 @@ struct scsi_xsense {
/* inquiry data */
struct scsi_inquiry {
u_char type;
#define SID_TYPE 0x1f
#define T_DIRECT 0x00
#define T_CDROM 0x05
u_char qual;
u_char version;
u_char rsvd;

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsivar.h,v 1.4 2005/12/11 12:17:19 christos Exp $ */
/* $NetBSD: scsivar.h,v 1.5 2024/05/09 15:11:11 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@ -52,5 +52,6 @@ void scsiabort(struct scsi_softc *, volatile struct scsidevice *);
int scsi_test_unit_rdy(int, int);
int scsi_request_sense(int, int, u_char *, unsigned int);
int scsi_read_capacity(int, int, u_char *, unsigned int);
int scsi_inquiry(int, int, u_char *, unsigned int);
int scsi_tt_read(int, int, u_char *, u_int, daddr_t, u_int);
int scsi_tt_write(int, int, u_char *, u_int, daddr_t, u_int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.12 2023/01/15 06:19:46 tsutsui Exp $ */
/* $NetBSD: sd.c,v 1.13 2024/05/09 15:11:11 tsutsui Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -67,6 +67,9 @@ struct sd_softc {
char sc_alive;
short sc_blkshift;
struct sdminilabel sc_pinfo;
#ifdef SUPPORT_CD
uint8_t sc_type;
#endif
};
#define SDRETRY 2
@ -82,6 +85,9 @@ sdinit(int ctlr, int unit)
{
struct sd_softc *ss = &sd_softc[ctlr][unit];
u_char stat;
#ifdef SUPPORT_CD
struct scsi_inquiry inqbuf;
#endif
int capbuf[2];
stat = scsi_test_unit_rdy(ctlr, unit);
@ -97,6 +103,20 @@ sdinit(int ctlr, int unit)
return 0;
}
}
#ifdef SUPPORT_CD
/*
* try to get the disk type.
*/
memset(&inqbuf, 0, sizeof(inqbuf));
stat = scsi_inquiry(ctlr, unit, (u_char *)&inqbuf, sizeof(inqbuf));
if (stat == 0) {
/* to fake a disklabel on CD-ROM */
ss->sc_type = inqbuf.type & SID_TYPE;
} else {
/* assume a disk by default */
ss->sc_type = T_DIRECT;
}
#endif
/*
* try to get the drive block size.
*/
@ -141,11 +161,22 @@ sdgetinfo(struct sd_softc *ss)
msg = getdisklabel(io_buf, lp);
if (msg) {
printf("sd(%d,%d,%d): WARNING: %s\n",
ss->sc_ctlr, ss->sc_unit, ss->sc_part, msg);
pi->npart = 3;
pi->offset[0] = pi->offset[1] = -1;
pi->offset[2] = 0;
#ifdef SUPPORT_CD
if (ss->sc_type == T_CDROM) {
/* assume a whole disk region is ISO9660 */
pi->npart = 3;
pi->offset[0] = 0;
pi->offset[1] = -1;
pi->offset[2] = 0;
} else
#endif
{
printf("sd(%d,%d,%d): WARNING: %s\n",
ss->sc_ctlr, ss->sc_unit, ss->sc_part, msg);
pi->npart = 3;
pi->offset[0] = pi->offset[1] = -1;
pi->offset[2] = 0;
}
} else {
pi->npart = lp->d_npartitions;
for (i = 0; i < pi->npart; i++)