/*-
* Copyright (c) 1993, 1994 Takumi Nakamura.
* Copyright (c) 1999, 2000 Itoh Yasufumi.
* Copyright (c) 2001 Minoura Makoto.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Takumi Nakamura.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#define PARTTBL_TOP (4) /* sector pos of part info in 512byte/sector */
#define NPART (15) /* total number of Human68k partitions */
#define MAXPART (6)
int
get_scsi_part(void)
{
union {
char pad[1024];
struct {
uint32_t magic; /* 0x5836384b ("X68k") */
uint32_t parttotal; /* total block# -1 */
uint32_t diskblocks;
uint32_t diskblocks2; /* backup? */
struct dos_partition parttbl[NPART];
} __packed;
} partbuf;
int i;
int part_top;
/*
* Read partition table.
* The actual partition table size we want to read is 256 bytes but
* raw_read() for SCSI requires bytelen a multiple of sector size
* (SCSI_CAP.blocksize). Human68k supports sector size only 256,
* 512 and 1024 so that we always use 1024 bytes fixed length buffer.
*/
raw_read(PARTTBL_TOP, SCSI_CAP.blocksize, &partbuf);
/*
* SCSI_PARTTOP is top sector # of this partition in sector size
* of this device (normally 512 bytes/sector).
* part_top is top block # of this partition in 1024 bytes/block.
* Human68k partition table uses 1024 bytes/block unit.
*/
part_top = SCSI_PARTTOP >> (2 - SCSI_BLKLEN);
for (i = 0; i < MAXPART; i++) {
if ((uint32_t)partbuf.parttbl[i].dp_start == part_top)
goto found;
}
BOOT_ERROR("Can't find this partition?");
/* NOTREACHED */
found:
/* bsd disklabel's c: means whole disk. Skip it */
if (i >= 2)
i++;
return i;
}
void
bootmain(void)
{
int bootdev, fd;
char bootdevstr[16];
u_long marks[MARK_MAX];