Fix building of libcntpr on ppc.
[reactos.git] / reactos / boot / freeldr / freeldr / arch / powerpc / prep.c
1 #include "freeldr.h"
2 #include "machine.h"
3 #include "ppcmmu/mmu.h"
4 #include "prep.h"
5
6 int prep_serial = 0x800003f8;
7
8 void sync() { __asm__("eieio\n\tsync"); }
9
10 /* Simple serial */
11
12 void PpcPrepPutChar( int ch ) {
13 if( ch == 0x0a ) {
14 SetPhysByte(prep_serial, 0x0d);
15 sync();
16 }
17 SetPhysByte(prep_serial, ch);
18 sync();
19 }
20
21 BOOLEAN PpcPrepDiskReadLogicalSectors
22 ( ULONG DriveNumber, ULONGLONG SectorNumber,
23 ULONG SectorCount, PVOID Buffer ) {
24 int secct;
25
26 for(secct = 0; secct < SectorCount; secct++)
27 {
28 ide_seek(&ide1_desc, SectorNumber + secct, 0);
29 ide_read(&ide1_desc, ((PCHAR)Buffer) + secct * 512, 512);
30 }
31 /* Never give up! */
32 return TRUE;
33 }
34
35 BOOLEAN PpcPrepConsKbHit()
36 {
37 return 1;
38 //return GetPhysByte(prep_serial+5) & 1;
39 }
40
41 int PpcPrepConsGetCh()
42 {
43 while(!PpcPrepConsKbHit());
44 return GetPhysByte(prep_serial);
45 }
46
47 void PpcPrepVideoClearScreen(UCHAR Attr)
48 {
49 printf("\033c");
50 }
51
52 VIDEODISPLAYMODE PpcPrepVideoSetDisplayMode( char *DisplayMode, BOOLEAN Init )
53 {
54 return VideoTextMode;
55 }
56
57 void PpcPrepVideoGetDisplaySize( PULONG Width, PULONG Height, PULONG Depth )
58 {
59 *Width = 80;
60 *Height = 25;
61 *Depth = 16;
62 }
63
64 void PpcPrepVideoPrepareForReactOS(BOOLEAN setup)
65 {
66 pci_setup(&pci1_desc);
67 }
68
69 int mmu_initialized = 0;
70
71 ULONG PpcPrepGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap,
72 ULONG MaxMemoryMapSize )
73 {
74 // xxx fixme
75 BiosMemoryMap[0].Type = 1;
76 BiosMemoryMap[0].BaseAddress = 0xe80000;
77 BiosMemoryMap[0].Length = (64 * 1024 * 1024) - BiosMemoryMap[0].BaseAddress;
78 if(!mmu_initialized)
79 {
80 MmuInit();
81 mmu_initialized = 1;
82 }
83 MmuSetMemorySize(BiosMemoryMap[0].Length + BiosMemoryMap[0].BaseAddress);
84 return 1;
85 }
86
87 void PpcPrepInit()
88 {
89 MachVtbl.ConsPutChar = PpcPrepPutChar;
90
91 printf("Serial on\n");
92
93 ide_setup( &ide1_desc );
94
95 MachVtbl.DiskReadLogicalSectors = PpcPrepDiskReadLogicalSectors;
96
97 MachVtbl.ConsKbHit = PpcPrepConsKbHit;
98 MachVtbl.ConsGetCh = PpcPrepConsGetCh;
99
100 MachVtbl.VideoClearScreen = PpcPrepVideoClearScreen;
101 MachVtbl.VideoSetDisplayMode = PpcPrepVideoSetDisplayMode;
102 MachVtbl.VideoGetDisplaySize = PpcPrepVideoGetDisplaySize;
103
104 MachVtbl.VideoPrepareForReactOS = PpcPrepVideoPrepareForReactOS;
105
106 MachVtbl.GetMemoryMap = PpcPrepGetMemoryMap;
107
108 printf( "FreeLDR version [%s]\n", GetFreeLoaderVersionString() );
109
110 BootMain( "" );
111 }
112