Chameleon

Chameleon Commit Details

Date:2011-06-26 02:12:02 (12 years 9 months ago)
Author:Evan Lojewski
Commit:1084
Parents: 1083
Message:BiosDisk Read() function working. Write() complete but untested
Changes:
M/branches/rewrite/i386/modules/BiosDisk/include/Disk.hpp
M/branches/rewrite/i386/modules/BiosDisk/Main.cpp
M/branches/rewrite/i386/modules/BiosDisk/BiosDisk.cpp

File differences

branches/rewrite/i386/modules/BiosDisk/include/Disk.hpp
1717
1818
1919
20
20
21
2122
2223
2324
virtual IOReturn Read(UInt64 sector, UInt64 size, UInt8* buffer) = 0;
virtual IOReturn Write(UInt64 sector, UInt64 size, UInt8* buffer) = 0;
virtual bool isValid() { return mName != NULL && mBytesPerSector; };
virtual bool isValid() { return mName != NULL && mBytesPerSector; };
virtual UInt32 bytesPerSector() { return mBytesPerSector; };
protected:
const char *mName;
const char *mBusType;
branches/rewrite/i386/modules/BiosDisk/Main.cpp
1414
1515
1616
17
18
1719
20
21
1822
23
24
1925
2026
27
28
2129
2230
2331
void BiosDisk_start()
{
UInt8* mbr = (UInt8*)malloc(512);
BiosDisk* disk = new BiosDisk("bios:/hd0/");
disk->Read(0, 1, mbr);
printf("mbr[0] = 0x%X\n", mbr[0]);
printf("mbr[510] = 0x%X\n", mbr[510]);
printf("mbr[511] = 0x%X\n", mbr[511]);
printf("This is a simple BootDisk_start test.\n");
delete disk;
halt();
}
branches/rewrite/i386/modules/BiosDisk/BiosDisk.cpp
9696
9797
9898
99
99
100
101
102
103
104
105
106
100107
101108
102109
103110
104111
112
105113
106
114
115
116
117
118
119
120
121
107122
108123
109124
110125
111126
112
127
113128
114129
115130
IOReturn BiosDisk::Read(UInt64 sector, UInt64 size, UInt8* buffer)
{
if(!isValid()) return kIOReturnNoDevice;
return kIOReturnSuccess;
// Assume EBIOS capable for now...
if(EBIOSRead(sector, size) == 0)
{
bcopy((void*)BIOS_ADDR, buffer, size * mBytesPerSector);
return kIOReturnSuccess;
}
else return kIOReturnIOError;
}
IOReturn BiosDisk::Write(UInt64 sector, UInt64 size, UInt8* buffer)
{
if(!isValid()) return kIOReturnNoDevice;
return kIOReturnNotWritable;
bcopy(buffer, (void*)BIOS_ADDR, size * mBytesPerSector);
if(EBIOSWrite(sector, size) == 0)
{
return kIOReturnSuccess;
}
else return kIOReturnIOError;
}
UInt8 BiosDisk::BIOSRead(UInt16 cylinder, UInt8 head, UInt8 sector, UInt8 count)
{
if(sector == 0) return -1;
sector++; // starts at 1
biosBuf_t bb;
int i;

Archive Download the corresponding diff file

Revision: 1084