*/
ULONG PpcGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap,
ULONG MaxMemoryMapSize ) {
- int i, memhandle, returned, total = 0, num_mem = 0;
+ int i, memhandle, mmuhandle, returned, total = 0, num_mem = 0;
int memdata[256];
+ printf("PpcGetMemoryMap(%d)\n", MaxMemoryMapSize);
+
ofw_getprop(chosen_package, "memory",
(char *)&memhandle, sizeof(memhandle));
+ ofw_getprop(chosen_package, "mmu",
+ (char *)&mmuhandle, sizeof(mmuhandle));
+
returned = ofw_getprop(memhandle, "available",
(char *)memdata, sizeof(memdata));
BiosMemoryMap[num_mem].Length = TOTAL_HEAP_NEEDED;
ofw_claim(BiosMemoryMap[num_mem].BaseAddress,
BiosMemoryMap[num_mem].Length, 0x1000); /* claim it */
+ printf("virt2phys(%x)->%x\n",
+ BiosMemoryMap[num_mem].BaseAddress,
+ ofw_virt2phys
+ (mmuhandle, BiosMemoryMap[num_mem].BaseAddress));
total += BiosMemoryMap[0].Length;
num_mem++;
}
}
BOOLEAN PpcDiskReadLogicalSectors( ULONG DriveNumber, ULONGLONG SectorNumber,
- ULONG SectorCount, PVOID Buffer ) {
+ ULONG SectorCount, PVOID Buffer ) {
int rlen = 0;
if( part_handle == -1 ) {
return FALSE;
}
- if( ofw_seek( part_handle, SectorNumber * 512 ) ) {
- printf("Seek to %x failed\n", SectorNumber * 512);
+ if( ofw_seek( part_handle,
+ (ULONG)(SectorNumber >> 25),
+ (ULONG)((SectorNumber * 512) & 0xffffffff) ) ) {
+ printf("Seek to %x failed\n", (ULONG)(SectorNumber * 512));
return FALSE;
}
- rlen = ofw_read( part_handle, Buffer, SectorCount * 512 );
+ rlen = ofw_read( part_handle, Buffer, (ULONG)(SectorCount * 512) );
return rlen > 0;
}
typedef unsigned int uint32_t;
void PpcInit( of_proxy the_ofproxy ) {
- int len;
+ int len, stdin_handle_chosen;
ofproxy = the_ofproxy;
- ofw_print_string("Made it into freeldr LE code ... bootstrap complete\n");
+ ofw_print_string("Freeldr PowerPC Init\n");
chosen_package = ofw_finddevice( "/chosen" );
+ ofw_print_string("Freeldr: chosen_package is ");
+ ofw_print_number(chosen_package);
+ ofw_print_string("\n");
+
ofw_getprop( chosen_package, "stdin",
- (char *)&stdin_handle, sizeof(stdin_handle) );
+ (char *)&stdin_handle_chosen, sizeof(stdin_handle_chosen) );
+
+ ofw_print_string("Freeldr: stdin_handle is ");
+ ofw_print_number(stdin_handle_chosen);
+ ofw_print_string("\n");
+
+ stdin_handle = stdin_handle_chosen;
/* stdin_handle = REV(stdin_handle); */
/////////////////////////////////////////////////////////////////////////////////////////////
ULONG FsType = 0; // Type of filesystem on boot device, set by FsOpenVolume()
+PVOID FsStaticBufferDisk = 0, FsStaticBufferData = 0;
/////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
{
CHAR ErrorText[80];
+ printf("FsOpenVolume: (disk=%d,start=%d,count=%d,type=%d)\n",
+ DriveNumber, StartSector, SectorCount, Type);
+
FsType = Type;
+ if( !FsStaticBufferDisk )
+ FsStaticBufferDisk = MmAllocateMemory( 0x20000 );
+ if( !FsStaticBufferDisk )
+ {
+ FileSystemError("could not allocate filesystem static buffer");
+ return FALSE;
+ }
+ FsStaticBufferData = ((PCHAR)FsStaticBufferDisk) + 0x10000;
+
switch (FsType)
{
case FS_FAT:
#define STACK16ADDR 0x7000 /* The 16-bit stack top will be at 0000:7000 */
#define STACK32ADDR 0x78000 /* The 32-bit stack top will be at 7000:8000, or 0x78000 */
+#ifdef _M_IX86
#define BIOSCALLBUFFER 0x78000 /* Buffer to store temporary data for any Int386() call */
#define BIOSCALLBUFSEGMENT 0x7800 /* Buffer to store temporary data for any Int386() call */
#define BIOSCALLBUFOFFSET 0x0000 /* Buffer to store temporary data for any Int386() call */
#define FILESYSBUFFER 0x80000 /* Buffer to store file system data (e.g. cluster buffer for FAT) */
#define DISKREADBUFFER 0x90000 /* Buffer to store data read in from the disk via the BIOS */
+#elif defined(_M_PPC)
+extern PVOID FsStaticBufferDisk, FsStaticBufferData;
+#define DISKREADBUFFER FsStaticBufferDisk
+#define FILESYSBUFFER FsStaticBufferData
+#endif
/* Makes "x" a global variable or label */
#define EXTERN(x) .global x; x: