3 #include "ppcmmu/mmu.h"
6 int prep_serial
= 0x800003f8;
7 extern int mem_range_end
;
9 void sync() { __asm__("eieio\n\tsync"); }
13 void PpcPrepPutChar( int ch
) {
15 SetPhysByte(prep_serial
, 0x0d);
18 SetPhysByte(prep_serial
, ch
);
22 BOOLEAN PpcPrepDiskReadLogicalSectors
23 ( ULONG DriveNumber
, ULONGLONG SectorNumber
,
24 ULONG SectorCount
, PVOID Buffer
) {
27 for(secct
= 0; secct
< SectorCount
; secct
++)
29 ide_seek(&ide1_desc
, SectorNumber
+ secct
, 0);
30 ide_read(&ide1_desc
, ((PCHAR
)Buffer
) + secct
* 512, 512);
36 BOOLEAN
PpcPrepConsKbHit()
39 //return GetPhysByte(prep_serial+5) & 1;
42 int PpcPrepConsGetCh()
44 while(!PpcPrepConsKbHit());
45 return GetPhysByte(prep_serial
);
48 void PpcPrepVideoClearScreen(UCHAR Attr
)
53 VIDEODISPLAYMODE
PpcPrepVideoSetDisplayMode( char *DisplayMode
, BOOLEAN Init
)
58 void PpcPrepVideoGetDisplaySize( PULONG Width
, PULONG Height
, PULONG Depth
)
65 VOID
PpcInitializeMmu(int max
);
67 ULONG
PpcPrepGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap
,
68 ULONG MaxMemoryMapSize
)
72 register int oldStore
= 0, newStore
= 0, change
= 0, oldmsr
;
74 __asm__("mfmsr %0\n" : "=r" (oldmsr
));
75 change
= oldmsr
& 0x6fff;
76 __asm__("mtmsr %0\n" : : "r" (change
));
78 // Find the last ram address in physical space ... this bypasses mapping
79 // but could run into non-ram objects right above ram. Usually systems
80 // aren't designed like that though.
81 for (physAddr
= 0x40000, change
= newStore
;
82 (physAddr
< 0x80000000) && (change
== newStore
);
85 oldStore
= GetPhys(physAddr
);
86 newStore
= (physAddr
& 0x1000) ? 0x55aa55aa : 0xaa55aa55;
87 SetPhys(physAddr
, newStore
);
88 change
= GetPhys(physAddr
);
89 SetPhys(physAddr
, oldStore
);
91 // Back off by one page
93 BiosMemoryMap
[0].BaseAddress
= 0x30000; // End of ppcmmu
94 BiosMemoryMap
[0].Type
= BiosMemoryUsable
;
95 BiosMemoryMap
[0].Length
= physAddr
- BiosMemoryMap
[0].BaseAddress
;
97 __asm__("mtmsr %0\n" : : "r" (oldmsr
));
99 mem_range_end
= physAddr
;
101 printf("Actual RAM: %d Mb\n", physAddr
>> 20);
105 /* Most PReP hardware is in standard locations, based on the corresponding
106 * hardware on PCs. */
107 PCONFIGURATION_COMPONENT_DATA
PpcPrepHwDetect() {
108 PCONFIGURATION_COMPONENT_DATA SystemKey
;
110 /* Create the 'System' key */
111 FldrCreateSystemKey(&SystemKey
);
113 printf("DetectHardware() Done\n");
125 MachVtbl
.ConsPutChar
= PpcPrepPutChar
;
127 printf("Serial on\n");
129 ide_setup( &ide1_desc
);
131 MachVtbl
.DiskReadLogicalSectors
= PpcPrepDiskReadLogicalSectors
;
133 MachVtbl
.ConsKbHit
= PpcPrepConsKbHit
;
134 MachVtbl
.ConsGetCh
= PpcPrepConsGetCh
;
136 MachVtbl
.VideoClearScreen
= PpcPrepVideoClearScreen
;
137 MachVtbl
.VideoSetDisplayMode
= PpcPrepVideoSetDisplayMode
;
138 MachVtbl
.VideoGetDisplaySize
= PpcPrepVideoGetDisplaySize
;
140 MachVtbl
.GetMemoryMap
= PpcPrepGetMemoryMap
;
141 MachVtbl
.HwDetect
= PpcPrepHwDetect
;
142 MachVtbl
.HwIdle
= PcPrepHwIdle
;
144 printf( "FreeLDR version [%s]\n", GetFreeLoaderVersionString() );