ReactOS  0.4.12-dev-919-gfc3b8d5
prep.c
Go to the documentation of this file.
1 #include "freeldr.h"
2 #include "machine.h"
3 #include "ppcmmu/mmu.h"
4 #include "prep.h"
5 
6 int prep_serial = 0x800003f8;
7 extern int mem_range_end;
8 
9 void sync() { __asm__("eieio\n\tsync"); }
10 
11 /* Simple serial */
12 
13 void PpcPrepPutChar( int ch ) {
14  if( ch == 0x0a ) {
15  SetPhysByte(prep_serial, 0x0d);
16  sync();
17  }
19  sync();
20 }
21 
23 ( ULONG DriveNumber, ULONGLONG SectorNumber,
25  int secct;
26 
27  for(secct = 0; secct < SectorCount; secct++)
28  {
29  ide_seek(&ide1_desc, SectorNumber + secct, 0);
30  ide_read(&ide1_desc, ((PCHAR)Buffer) + secct * 512, 512);
31  }
32  /* Never give up! */
33  return TRUE;
34 }
35 
37 {
38  return 1;
39  //return GetPhysByte(prep_serial+5) & 1;
40 }
41 
43 {
44  while(!PpcPrepConsKbHit());
45  return GetPhysByte(prep_serial);
46 }
47 
49 {
50  printf("\033c");
51 }
52 
54 {
55  return VideoTextMode;
56 }
57 
59 {
60  *Width = 80;
61  *Height = 25;
62  *Depth = 16;
63 }
64 
66 
68  ULONG MaxMemoryMapSize )
69 {
70  // Probe memory
71  paddr_t physAddr;
72  register int oldStore = 0, newStore = 0, change = 0, oldmsr;
73 
74  __asm__("mfmsr %0\n" : "=r" (oldmsr));
75  change = oldmsr & 0x6fff;
76  __asm__("mtmsr %0\n" : : "r" (change));
77 
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);
83  physAddr += 1 << 12)
84  {
85  oldStore = GetPhys(physAddr);
86  newStore = (physAddr & 0x1000) ? 0x55aa55aa : 0xaa55aa55;
87  SetPhys(physAddr, newStore);
88  change = GetPhys(physAddr);
89  SetPhys(physAddr, oldStore);
90  }
91  // Back off by one page
92  physAddr -= 0x1000;
93  BiosMemoryMap[0].BaseAddress = 0x30000; // End of ppcmmu
95  BiosMemoryMap[0].Length = physAddr - BiosMemoryMap[0].BaseAddress;
96 
97  __asm__("mtmsr %0\n" : : "r" (oldmsr));
98 
99  mem_range_end = physAddr;
100 
101  printf("Actual RAM: %d Mb\n", physAddr >> 20);
102  return 1;
103 }
104 
105 /* Most PReP hardware is in standard locations, based on the corresponding
106  * hardware on PCs. */
109 
110  /* Create the 'System' key */
111  FldrCreateSystemKey(&SystemKey);
112 
113  printf("DetectHardware() Done\n");
114  return SystemKey;
115 }
116 
117 VOID
119 {
120  /* UNIMPLEMENTED */
121 }
122 
124 {
126 
127  printf("Serial on\n");
128 
129  ide_setup( &ide1_desc );
130 
132 
135 
139 
142  MachVtbl.HwIdle = PcPrepHwIdle;
143 
144  printf( "FreeLDR version [%s]\n", GetFreeLoaderVersionString() );
145 
146  BootMain( "" );
147 }
148 
PCONFIGURATION_COMPONENT_DATA PpcPrepHwDetect()
Definition: prep.c:107
signed char * PCHAR
Definition: retypes.h:7
void PpcPrepPutChar(int ch)
Definition: prep.c:13
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:62
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:656
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
int GetPhysByte(int Addr)
int mem_range_end
Definition: mach.c:168
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(VOID)
Definition: machine.h:75
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap
Definition: meminit.c:33
int ide_read(void *extension, char *buffer, int bytes)
Definition: prep_ide.c:50
unsigned long paddr_t
Definition: mmu.h:89
void BootMain(LPSTR CmdLine)
void ide_seek(void *extension, int low, int high)
Definition: prep_ide.c:17
const PCSTR GetFreeLoaderVersionString(VOID)
Definition: version.c:32
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
unsigned char BOOLEAN
Definition: bufpool.h:45
BOOLEAN PpcPrepDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: prep.c:23
int PpcPrepConsGetCh()
Definition: prep.c:42
int prep_serial
Definition: prep.c:6
struct _idectl_desc ide1_desc
Definition: prep_ide.c:15
void ide_setup(void *extension)
Definition: prep_ide.c:73
uint64_t ULONGLONG
Definition: typedefs.h:65
ULONG GetPhys(ULONG Addr)
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:65
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:116
unsigned char UCHAR
Definition: xmlstorage.h:181
void sync()
Definition: prep.c:9
void PpcPrepInit()
Definition: prep.c:123
VIDEODISPLAYMODE PpcPrepVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init)
Definition: prep.c:53
enum tagVIDEODISPLAYMODE VIDEODISPLAYMODE
ULONG SectorCount
Definition: part_xbox.c:32
int(* ConsGetCh)(VOID)
Definition: machine.h:43
void PpcPrepVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: prep.c:58
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41
VOID(* HwIdle)(VOID)
Definition: machine.h:76
unsigned int * PULONG
Definition: retypes.h:1
void PpcPrepVideoClearScreen(UCHAR Attr)
Definition: prep.c:48
VOID PpcInitializeMmu(int max)
BOOLEAN PpcPrepConsKbHit()
Definition: prep.c:36
unsigned int ULONG
Definition: retypes.h:1
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
VOID NTAPI FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
Definition: archwsup.c:89
ULONG PpcPrepGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
Definition: prep.c:67
MACHVTBL MachVtbl
Definition: machine.c:21
void SetPhys(ULONG Addr, ULONG Data)
void SetPhysByte(ULONG Addr, ULONG Data)
VOID PpcPrepHwIdle(VOID)
Definition: prep.c:118
#define printf
Definition: config.h:203