freebsd-dev/sys/i386/boot/cdboot/boot.h

182 lines
5.5 KiB
C
Raw Normal View History

(Part #2, after the Internet link broke totally yesterday.) This is the long-threatened ISO 9660 CD-ROM bootstrap code. This work has been sponsored by Plutotech International, Inc (who paid the initial work), and interface business GmbH (where i did most of the work). A big thanks also goes to Bruce Evans, for his continuing help and answering my stupid questions. The code is basically functioning, with the following caveats: . Rock Ridge attributes are not yet supported. . Only SCSI CD-ROMs are supported, since i fail to see any possibility to determine the drive type using BIOS functions. (Even for hard disks, this determination is done by a big hack only.) . El Torito specifies a lot of crap and useless misfeatures, but crucial things like the ability to figure out the CD TOC have been ``forgotten''. Thus, if you wanna boot a multisession CD, you need to know at which CD block your session starts, and need to speciffy it using the @ clause. . None of the CD-ROM controllers i've seen so far implements the full El Torito specification at all. Adaptec is probably the closest, but they miss on non-emulation booting (which would be the most logical choice for us). Thus, the current code bloats the 7.5 KB boot code up to 1.44 MB, in order to fake a `floppy' image. If you wanna use it, specify this file as the boot image on the command-line of the mksiosfs command (option -b). Caveat emptor: some versions of the Adaptec BIOS might even fail to access the CD-ROM at all, using the BIOS functions. I think i've notice this for ver 1.26, the code has been tested with ver 1.23. The boot string is as follows: [@sess-start] [filename] [-flags] sess-start Extend # where the last session starts, measured in CD-ROM blocks. filename As usual, but the input is case-insensitive by now (since we don't grok RR anyway). flags As usual, but -C (use CDROM root f/s) is default, so specifying -C will decactivate this option (which is probably not what you want :). A lot of cleanup work is probably required, and some of the files could/should be merged back to biosboot, perhaps made conditional on some #ifdef. The malloc implementation that comes with cdboot might also be useful for kzipboot. (I needed a malloc() since the root dir ain't fixed in size on a CD.) I've been testing all this with a 2.2-STABLE as the base for biosboot. I don't expect too many surprises, although i know the biosboot stuff has been changed a lot in -current lately. I'm sure Bruce will comment on all this here anyway. :-)
1997-07-11 05:52:41 +00:00
/*
* Mach Operating System
* Copyright (c) 1992, 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:03 rpd
* $Id: boot.h,v 1.1 1997/07/11 05:52:38 joerg Exp $
(Part #2, after the Internet link broke totally yesterday.) This is the long-threatened ISO 9660 CD-ROM bootstrap code. This work has been sponsored by Plutotech International, Inc (who paid the initial work), and interface business GmbH (where i did most of the work). A big thanks also goes to Bruce Evans, for his continuing help and answering my stupid questions. The code is basically functioning, with the following caveats: . Rock Ridge attributes are not yet supported. . Only SCSI CD-ROMs are supported, since i fail to see any possibility to determine the drive type using BIOS functions. (Even for hard disks, this determination is done by a big hack only.) . El Torito specifies a lot of crap and useless misfeatures, but crucial things like the ability to figure out the CD TOC have been ``forgotten''. Thus, if you wanna boot a multisession CD, you need to know at which CD block your session starts, and need to speciffy it using the @ clause. . None of the CD-ROM controllers i've seen so far implements the full El Torito specification at all. Adaptec is probably the closest, but they miss on non-emulation booting (which would be the most logical choice for us). Thus, the current code bloats the 7.5 KB boot code up to 1.44 MB, in order to fake a `floppy' image. If you wanna use it, specify this file as the boot image on the command-line of the mksiosfs command (option -b). Caveat emptor: some versions of the Adaptec BIOS might even fail to access the CD-ROM at all, using the BIOS functions. I think i've notice this for ver 1.26, the code has been tested with ver 1.23. The boot string is as follows: [@sess-start] [filename] [-flags] sess-start Extend # where the last session starts, measured in CD-ROM blocks. filename As usual, but the input is case-insensitive by now (since we don't grok RR anyway). flags As usual, but -C (use CDROM root f/s) is default, so specifying -C will decactivate this option (which is probably not what you want :). A lot of cleanup work is probably required, and some of the files could/should be merged back to biosboot, perhaps made conditional on some #ifdef. The malloc implementation that comes with cdboot might also be useful for kzipboot. (I needed a malloc() since the root dir ain't fixed in size on a CD.) I've been testing all this with a 2.2-STABLE as the base for biosboot. I don't expect too many surprises, although i know the biosboot stuff has been changed a lot in -current lately. I'm sure Bruce will comment on all this here anyway. :-)
1997-07-11 05:52:41 +00:00
*/
/*
* Extensions for El Torito CD-ROM booting:
*
* Copyright <EFBFBD> 1997 Pluto Technologies International, Inc. Boulder CO
* Copyright <EFBFBD> 1997 interface business GmbH, Dresden.
* All rights reserved.
*
* This code has been written by J<EFBFBD>rg Wunsch, Dresden.
* Direct comments to <joerg_wunsch@interface-business.de>.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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.
*/
#include <sys/param.h>
#include <sys/time.h>
/*
* Specification packet per El Torito, BIOS int 0x13 fn 0x4b00/0x4b01
*/
struct specpacket
{
u_char size; /* must be 0x13 */
u_char mediatype; /*
* 0 - no emulation
* 1 - 1.2 MB floppy
* 2 - 1.44 MB floppy
* 3 - 2.88 MB floppy
* 4 - hard disk C:
*/
u_char drvno; /* emulated drive number */
u_char ctrlindx; /* controller index, see El Torito */
u_int32_t lba; /* LBA of emulated disk drive */
u_int16_t devspec; /* device specification, see El Torito */
u_int16_t ubufseg; /* user buffer segment */
u_int16_t loadseg; /* load segment; 0 => use BIOS default 0x7c0 */
u_int16_t seccnt; /* number of auto-loaded (virtual) sectors */
u_char cyls; /* same values as in int 0x13, fn 8 */
u_char secs;
u_char heads;
};
/*
* Disk address packet for extended BIOS int 0x13 fn's 0x41...0x48.
*/
struct daddrpacket
{
u_char size; /* size of daddrpacket, must be 0x10 */
u_char reserved1;
u_char nblocks; /*
* number of 512-byte blocks to transfer,
* must be <= 127
*/
u_char reserved2;
u_int16_t boffs; /* bseg:boffs denominate the transfer buffer */
u_int16_t bseg;
u_int32_t lba; /* actually a 64-bit type, but 64-bit arith */
u_int32_t lbahigh; /* is expensive, and we don't really need it */
};
#ifdef DEBUG
# define DPRINTF(x) printf x
#else
# define DPRINTF(x)
#endif
/* asm.S */
#if ASM_ONLY
void real_to_prot(void);
void prot_to_real(void);
#endif
void startprog(unsigned int physaddr, int howto, int bootdev,
/* XXX struct bootinfo * */ unsigned int bootinfo);
void pbzero(void *dst, size_t count);
void pcpy(const void *src, void *dst, size_t count);
/* bios.S */
int biosread(int dev, int cyl, int head, int sec, int nsec, void *offset);
int getbootspec(struct specpacket *offset);
int biosreadlba(struct daddrpacket *daddr);
void putc(int c);
int getc(void);
int ischar(void);
int get_diskinfo(int drive);
int memsize(int extended);
/* boot.c */
extern int loadflags;
void boot(int drive);
/* boot2.S */
void boot2(void);
/* cdrom.c */
extern u_int32_t sessionstart;
int devopen(u_int32_t session);
void seek(u_int32_t offs);
int read(u_char *addr, size_t size);
int xread(u_char *addr, size_t size);
int openrd(char *name);
/* io.c */
void gateA20(void);
void printf(const char *format, ...);
void putchar(int c);
void delay1ms(void);
int gets(char *buf);
int strcasecmp(const char *s1, const char *s2);
int strcmp(const char *s1, const char *s2);
(Part #2, after the Internet link broke totally yesterday.) This is the long-threatened ISO 9660 CD-ROM bootstrap code. This work has been sponsored by Plutotech International, Inc (who paid the initial work), and interface business GmbH (where i did most of the work). A big thanks also goes to Bruce Evans, for his continuing help and answering my stupid questions. The code is basically functioning, with the following caveats: . Rock Ridge attributes are not yet supported. . Only SCSI CD-ROMs are supported, since i fail to see any possibility to determine the drive type using BIOS functions. (Even for hard disks, this determination is done by a big hack only.) . El Torito specifies a lot of crap and useless misfeatures, but crucial things like the ability to figure out the CD TOC have been ``forgotten''. Thus, if you wanna boot a multisession CD, you need to know at which CD block your session starts, and need to speciffy it using the @ clause. . None of the CD-ROM controllers i've seen so far implements the full El Torito specification at all. Adaptec is probably the closest, but they miss on non-emulation booting (which would be the most logical choice for us). Thus, the current code bloats the 7.5 KB boot code up to 1.44 MB, in order to fake a `floppy' image. If you wanna use it, specify this file as the boot image on the command-line of the mksiosfs command (option -b). Caveat emptor: some versions of the Adaptec BIOS might even fail to access the CD-ROM at all, using the BIOS functions. I think i've notice this for ver 1.26, the code has been tested with ver 1.23. The boot string is as follows: [@sess-start] [filename] [-flags] sess-start Extend # where the last session starts, measured in CD-ROM blocks. filename As usual, but the input is case-insensitive by now (since we don't grok RR anyway). flags As usual, but -C (use CDROM root f/s) is default, so specifying -C will decactivate this option (which is probably not what you want :). A lot of cleanup work is probably required, and some of the files could/should be merged back to biosboot, perhaps made conditional on some #ifdef. The malloc implementation that comes with cdboot might also be useful for kzipboot. (I needed a malloc() since the root dir ain't fixed in size on a CD.) I've been testing all this with a 2.2-STABLE as the base for biosboot. I don't expect too many surprises, although i know the biosboot stuff has been changed a lot in -current lately. I'm sure Bruce will comment on all this here anyway. :-)
1997-07-11 05:52:41 +00:00
void bcopy(const void *from, void *to, size_t len);
void twiddle(void);
/* probe_keyboard.c */
int probe_keyboard(void);
/* serial.S */
void serial_putc(int ch);
int serial_getc(void);
int serial_ischar(void);
void init_serial(void);
/* table.c */
extern char *devs[];
extern unsigned long tw_chars;
/* malloc.c */
void *malloc(size_t size);
void free(void *chunk);
/* linker stuff */
extern void end;