- add a gBootDriveAPI variable telling which method was used to load,
- move gBoot* out of the boot sector, - fix the FAT params to actually indicate 1.44kB floppy, - fix the FloppyDrive class to also use 18 sectors/track, so now tarfs won't get data from start of disk when on the middle. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30481 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
89b87f2ba5
commit
12442ce54b
@ -15,7 +15,7 @@
|
||||
#include "Handle.h"
|
||||
#include "toscalls.h"
|
||||
|
||||
#define TRACE_DEVICES
|
||||
//#define TRACE_DEVICES
|
||||
#ifdef TRACE_DEVICES
|
||||
# define TRACE(x) dprintf x
|
||||
#else
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
// exported from shell.S
|
||||
extern uint8 gBootedFromImage;
|
||||
extern uint8 gBootDriveAPI; // ATARI_BOOT_DRIVE_API_*
|
||||
extern uint8 gBootDriveID;
|
||||
extern uint32 gBootPartitionOffset;
|
||||
|
||||
@ -702,8 +703,11 @@ FloppyDrive::FloppyDrive(int handle)
|
||||
dprintf("getting drive parameters for: %u failed!\n", fHandle);
|
||||
return;
|
||||
}
|
||||
// XXX: probe! this is a std 1.44kB floppy
|
||||
fBlockSize = 512;
|
||||
fParameters.sectors = 1440 * 1024 / 512;
|
||||
fParameters.sectors_per_track = 18;
|
||||
fParameters.heads = 2;
|
||||
fSize = fParameters.sectors * fBlockSize;
|
||||
fHasParameters = false;
|
||||
/*
|
||||
@ -797,12 +801,32 @@ FloppyDrive::FillIdentifier()
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
hexdump(uint8 *buf, uint32 offset)
|
||||
{
|
||||
// hexdump
|
||||
|
||||
for (int i = 0; i < 512; i++) {
|
||||
if ((i % 16) == 0)
|
||||
TRACE(("%08lx ", offset+i));
|
||||
if ((i % 16) == 8)
|
||||
TRACE((" "));
|
||||
TRACE((" %02x", buf[i]));
|
||||
|
||||
if ((i % 16) == 15)
|
||||
TRACE(("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
FloppyDrive::ReadBlocks(void *buffer, off_t first, int32 count)
|
||||
{
|
||||
int sectorsPerBlocks = (fBlockSize / 512);
|
||||
int sectorsPerTrack = fParameters.sectors_per_track;
|
||||
int heads = fParameters.heads;
|
||||
int32 ret;
|
||||
TRACE(("FloppyDrive::%s(%Ld,%ld) (%d)\n", __FUNCTION__, first, count, fHandle));
|
||||
//TRACE(("FloppyDrive::%s(%Ld,%ld) (%d)\n", __FUNCTION__, first, count, fHandle));
|
||||
// force single sector reads to avoid crossing track boundaries
|
||||
for (int i = 0; i < count; i++) {
|
||||
uint8 *buf = (uint8 *)buffer;
|
||||
@ -810,17 +834,23 @@ FloppyDrive::ReadBlocks(void *buffer, off_t first, int32 count)
|
||||
|
||||
int16 track, side, sect;
|
||||
sect = (first + i) * sectorsPerBlocks;
|
||||
track = sect / (9 * 2);
|
||||
side = (sect / 9) % 2;
|
||||
sect %= 9;
|
||||
track = sect / (sectorsPerTrack * heads);
|
||||
side = (sect / sectorsPerTrack) % heads;
|
||||
sect %= sectorsPerTrack;
|
||||
sect++; // 1-based
|
||||
|
||||
|
||||
TRACE(("FloppyDrive::%s: THS: %d %d %d\n", __FUNCTION__, track, side, sect));
|
||||
/*
|
||||
TRACE(("FloppyDrive::%s: THS: %d %d %d\n",
|
||||
__FUNCTION__, track, side, sect));
|
||||
*/
|
||||
ret = Floprd(buf, 0L, fHandle, sect, track, side, 1);
|
||||
if (ret < 0)
|
||||
return toserror(ret);
|
||||
//if (first >= 1440)
|
||||
//hexdump(buf, (uint32)(first+i)*512);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -975,7 +1005,7 @@ XHDIDrive::XHDIDrive(int handle, uint16 major, uint16 minor)
|
||||
|
||||
fMajor = major;
|
||||
fMinor = minor;
|
||||
TRACE(("XHDIDrive::%s(%d, %d,%d)\n", __FUNCTION__, handle, fMajor, fMinor));
|
||||
TRACE(("XHDIDrive::%s(%d, %d, %d)\n", __FUNCTION__, handle, fMajor, fMinor));
|
||||
|
||||
product[32] = '\0';
|
||||
err = XHInqTarget(major, minor, &fBlockSize, &devflags, product);
|
||||
@ -1107,12 +1137,22 @@ platform_add_boot_device(struct stage2_args *args, NodeList *devicesList)
|
||||
//XXX: FIXME
|
||||
//BlockHandle *drive = new(nothrow) BlockHandle(gBootDriveID);
|
||||
BlockHandle *drive;
|
||||
switch (gBootDriveID) {
|
||||
case 0:
|
||||
case 1:
|
||||
switch (gBootDriveAPI) {
|
||||
case ATARI_BOOT_DRVAPI_FLOPPY:
|
||||
drive = new(nothrow) FloppyDrive(gBootDriveID);
|
||||
break;
|
||||
/*
|
||||
case ATARI_BOOT_DRVAPI_XBIOS:
|
||||
drive = new(nothrow) DMADrive(gBootDriveID);
|
||||
break;
|
||||
*/
|
||||
case ATARI_BOOT_DRVAPI_XHDI:
|
||||
drive = new(nothrow) XHDIDrive(gBootDriveID, gBootDriveID, 0);
|
||||
break;
|
||||
case ATARI_BOOT_DRVAPI_UNKNOWN:
|
||||
default:
|
||||
dprintf("unknown boot drive API %d\n", gBootDriveAPI);
|
||||
return B_ERROR;
|
||||
drive = new(nothrow) BIOSDrive(gBootDriveID);
|
||||
}
|
||||
if (drive->InitCheck() != B_OK) {
|
||||
|
@ -56,22 +56,25 @@ _bs_entry:
|
||||
|
||||
//FAT lookalike to avoid nasty things from happening
|
||||
// http://alive.atari.org/alive10/btmania.php
|
||||
// MS-DOS values :
|
||||
// http://support.microsoft.com/kb/75131/en
|
||||
// http://alumnus.caltech.edu/~pje/dosfiles.html
|
||||
.ascii "Haiku "
|
||||
.byte 0xbe, 0x50, 0x38 // id
|
||||
//LE
|
||||
//LITTLE ENDIAN!
|
||||
.byte 0x00, 0x02 //BPS
|
||||
.byte 0x02 //SPC
|
||||
//.byte 0x00 //???
|
||||
.byte 0x00, 0x02 //RES - number of reserved sectors
|
||||
.byte 0x00//0x02 //NFATS
|
||||
.byte 0x00/*70*/, 0x00 //NDIRS
|
||||
.byte 0xa0, 0x05 //NSECTS
|
||||
.byte 0xf9 //MEDIA
|
||||
.byte 0x05, 0x00 //SPF
|
||||
.byte 0x00 //NFATS
|
||||
.byte 0x00, 0x00 //NDIRS
|
||||
.byte 0x40, 0x0b //NSECTS
|
||||
.byte 0xf0 //MEDIA
|
||||
.byte 0x05, 0x00 //SPF
|
||||
_fat_spt:
|
||||
.byte 0x09, 0x00 //SPT
|
||||
.byte 0x02, 0x00 //NSIDES
|
||||
.byte 0x00, 0x00 //NHID
|
||||
.byte 0x12, 0x00 //SPT
|
||||
.byte 0x02, 0x00 //NSIDES
|
||||
.byte 0x00, 0x00 //NHID
|
||||
// we're done
|
||||
|
||||
sNumSectors:
|
||||
@ -79,7 +82,8 @@ sNumSectors:
|
||||
// written by the "makeflop" command in 512 byte blocks
|
||||
// 0x180 is the allowed maximum, as the zipped TAR with the
|
||||
// kernel and the boot module might start at offset 192 kB
|
||||
.word 0x0300 //0x0180
|
||||
//.word 0x0300 //0x0180
|
||||
.word BOOT_ARCHIVE_IMAGE_OFFSET*2
|
||||
|
||||
real_entry:
|
||||
|
||||
@ -125,16 +129,20 @@ floppy_start:
|
||||
tst.w %d0
|
||||
bne load_failed
|
||||
floppy_done:
|
||||
lea h4,%a0
|
||||
bsr puts
|
||||
// setup stack
|
||||
move.l #ATARI_ZBEOS_STACK_END,%sp
|
||||
lea h5,%a0
|
||||
bsr puts
|
||||
move.l #0,%d0
|
||||
//jmp ATARI_ZBEOS_BASE+512
|
||||
|
||||
move.b #ATARI_BOOT_DRVAPI_FLOPPY,ATARI_ZBEOS_BASE + gBootDriveAPI - _bs_entry
|
||||
move.w TOSVAR_bootdev,%d0
|
||||
// XXX: use uint16 ??
|
||||
move.b %d0,ATARI_ZBEOS_BASE + gBootDriveID - _bs_entry
|
||||
move.b #1,ATARI_ZBEOS_BASE + gBootedFromImage - _bs_entry
|
||||
|
||||
lea msg_j1,%a0
|
||||
bsr puts
|
||||
move.l #0,%d0
|
||||
|
||||
jmp _start
|
||||
|
||||
load_failed:
|
||||
@ -310,18 +318,6 @@ failure_string:
|
||||
// .string "."
|
||||
|
||||
|
||||
saved_super_stack:
|
||||
.long 0
|
||||
|
||||
GLOBAL(gBootedFromImage):
|
||||
.byte 0
|
||||
|
||||
GLOBAL(gBootDriveID):
|
||||
.byte 0
|
||||
|
||||
GLOBAL(gBootPartitionOffset):
|
||||
.long 0
|
||||
|
||||
|
||||
|
||||
putx:
|
||||
@ -477,6 +473,27 @@ copysect_loop:
|
||||
// all done
|
||||
super_done:
|
||||
// XXX: copy the rest !
|
||||
move.b #ATARI_BOOT_DRVAPI_FLOPPY,ATARI_ZBEOS_BASE + gBootDriveAPI - _bs_entry
|
||||
move.b #0,ATARI_ZBEOS_BASE + gBootDriveID - _bs_entry
|
||||
move.b #1,ATARI_ZBEOS_BASE + gBootedFromImage - _bs_entry
|
||||
|
||||
move.l #0,%d0
|
||||
|
||||
//jmp ATARI_ZBEOS_BASE+512
|
||||
jmp _start
|
||||
|
||||
saved_super_stack:
|
||||
.long 0
|
||||
|
||||
GLOBAL(gBootedFromImage):
|
||||
.byte 0
|
||||
|
||||
GLOBAL(gBootDriveAPI):
|
||||
.byte ATARI_BOOT_DRVAPI_UNKNOWN
|
||||
|
||||
GLOBAL(gBootDriveID):
|
||||
.byte 0
|
||||
|
||||
GLOBAL(gBootPartitionOffset):
|
||||
.long 0
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
* http://www.fortunecity.com/skyscraper/apple/308/html/chap3.htm
|
||||
* http://leonard.oxg.free.fr/articles/multi_atari/multi_atari.html
|
||||
* http://alive.atari.org/alive10/btmania.php
|
||||
* AHDI boot args:
|
||||
* http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/atari/stand/xxboot/ahdi-xxboot/xxboot.ahdi.S
|
||||
* gas stuff:
|
||||
* http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_chapter/as_18.html#SEC214
|
||||
*
|
||||
|
@ -809,6 +809,18 @@ extern void nat_feat_debugprintf(const char *str);
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
|
||||
/*
|
||||
* Drive API used by the bootsector
|
||||
* gBootDriveAPI is set to one of those
|
||||
* not all are implemented
|
||||
*/
|
||||
#define ATARI_BOOT_DRVAPI_UNKNOWN 0
|
||||
#define ATARI_BOOT_DRVAPI_FLOPPY 1 // Floprd()
|
||||
#define ATARI_BOOT_DRVAPI_BIOS 2 // Rwabs()
|
||||
#define ATARI_BOOT_DRVAPI_XBIOS 3 // DMAread()
|
||||
#define ATARI_BOOT_DRVAPI_XHDI 4 // XHReadWrite()
|
||||
#define ATARI_BOOT_DRVAPI_METADOS 5 // Metaread()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user