ReactOS  0.4.14-dev-49-gfb4591c
prep.c File Reference
#include "freeldr.h"
#include "machine.h"
#include "ppcmmu/mmu.h"
#include "prep.h"
Include dependency graph for prep.c:

Go to the source code of this file.

Functions

void sync ()
 
void PpcPrepPutChar (int ch)
 
BOOLEAN PpcPrepDiskReadLogicalSectors (ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
 
BOOLEAN PpcPrepConsKbHit ()
 
int PpcPrepConsGetCh ()
 
void PpcPrepVideoClearScreen (UCHAR Attr)
 
VIDEODISPLAYMODE PpcPrepVideoSetDisplayMode (char *DisplayMode, BOOLEAN Init)
 
void PpcPrepVideoGetDisplaySize (PULONG Width, PULONG Height, PULONG Depth)
 
VOID PpcInitializeMmu (int max)
 
ULONG PpcPrepGetMemoryMap (PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
 
PCONFIGURATION_COMPONENT_DATA PpcPrepHwDetect ()
 
VOID PpcPrepHwIdle (VOID)
 
void PpcPrepInit ()
 

Variables

int prep_serial = 0x800003f8
 
int mem_range_end
 

Function Documentation

◆ PpcInitializeMmu()

VOID PpcInitializeMmu ( int  max)

◆ PpcPrepConsGetCh()

int PpcPrepConsGetCh ( )

Definition at line 42 of file prep.c.

43 {
44  while(!PpcPrepConsKbHit());
45  return GetPhysByte(prep_serial);
46 }
int GetPhysByte(int Addr)
int prep_serial
Definition: prep.c:6
BOOLEAN PpcPrepConsKbHit()
Definition: prep.c:36

Referenced by PpcPrepInit().

◆ PpcPrepConsKbHit()

BOOLEAN PpcPrepConsKbHit ( )

Definition at line 36 of file prep.c.

37 {
38  return 1;
39  //return GetPhysByte(prep_serial+5) & 1;
40 }

Referenced by PpcPrepConsGetCh(), and PpcPrepInit().

◆ PpcPrepDiskReadLogicalSectors()

BOOLEAN PpcPrepDiskReadLogicalSectors ( ULONG  DriveNumber,
ULONGLONG  SectorNumber,
ULONG  SectorCount,
PVOID  Buffer 
)

Definition at line 23 of file prep.c.

24  {
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 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
int ide_read(void *extension, char *buffer, int bytes)
Definition: prep_ide.c:50
void ide_seek(void *extension, int low, int high)
Definition: prep_ide.c:17
Definition: bufpool.h:45
struct _idectl_desc ide1_desc
Definition: prep_ide.c:15
ULONG SectorCount
Definition: part_xbox.c:32

Referenced by PpcPrepInit().

◆ PpcPrepGetMemoryMap()

ULONG PpcPrepGetMemoryMap ( PBIOS_MEMORY_MAP  BiosMemoryMap,
ULONG  MaxMemoryMapSize 
)

Definition at line 67 of file prep.c.

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 }
int mem_range_end
Definition: mach.c:167
PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap
Definition: meminit.c:33
unsigned long paddr_t
Definition: mmu.h:89
__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")
ULONG GetPhys(ULONG Addr)
void SetPhys(ULONG Addr, ULONG Data)
#define printf
Definition: config.h:203

Referenced by PpcPrepInit().

◆ PpcPrepHwDetect()

PCONFIGURATION_COMPONENT_DATA PpcPrepHwDetect ( )

Definition at line 107 of file prep.c.

107  {
109 
110  /* Create the 'System' key */
111  FldrCreateSystemKey(&SystemKey);
112 
113  printf("DetectHardware() Done\n");
114  return SystemKey;
115 }
VOID NTAPI FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
Definition: archwsup.c:89
#define printf
Definition: config.h:203

Referenced by PpcPrepInit().

◆ PpcPrepHwIdle()

VOID PpcPrepHwIdle ( VOID  )

Definition at line 118 of file prep.c.

119 {
120  /* UNIMPLEMENTED */
121 }

◆ PpcPrepInit()

void PpcPrepInit ( void  )

Definition at line 123 of file prep.c.

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", FrLdrVersionString );
145 
146  BootMain( "" );
147 }
PCONFIGURATION_COMPONENT_DATA PpcPrepHwDetect()
Definition: prep.c:107
void PpcPrepPutChar(int ch)
Definition: prep.c:13
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:63
void BootMain(PSTR CmdLine)
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(VOID)
Definition: machine.h:77
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
const PCSTR FrLdrVersionString
Definition: freeldr.c:32
BOOLEAN PpcPrepDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: prep.c:23
int PpcPrepConsGetCh()
Definition: prep.c:42
struct _idectl_desc ide1_desc
Definition: prep_ide.c:15
void ide_setup(void *extension)
Definition: prep_ide.c:73
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:67
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
VIDEODISPLAYMODE PpcPrepVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init)
Definition: prep.c:53
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
MACHVTBL MachVtbl
Definition: arcemul.c:21
VOID(* HwIdle)(VOID)
Definition: machine.h:78
void PpcPrepVideoClearScreen(UCHAR Attr)
Definition: prep.c:48
BOOLEAN PpcPrepConsKbHit()
Definition: prep.c:36
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
ULONG PpcPrepGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
Definition: prep.c:67
#define printf
Definition: config.h:203

Referenced by PpcInit(), and PpcOfwInit().

◆ PpcPrepPutChar()

void PpcPrepPutChar ( int  ch)

Definition at line 13 of file prep.c.

13  {
14  if( ch == 0x0a ) {
15  SetPhysByte(prep_serial, 0x0d);
16  sync();
17  }
19  sync();
20 }
int prep_serial
Definition: prep.c:6
void sync()
Definition: prep.c:9
void SetPhysByte(ULONG Addr, ULONG Data)

Referenced by PpcPrepInit().

◆ PpcPrepVideoClearScreen()

void PpcPrepVideoClearScreen ( UCHAR  Attr)

Definition at line 48 of file prep.c.

49 {
50  printf("\033c");
51 }
#define printf
Definition: config.h:203

Referenced by PpcPrepInit().

◆ PpcPrepVideoGetDisplaySize()

void PpcPrepVideoGetDisplaySize ( PULONG  Width,
PULONG  Height,
PULONG  Depth 
)

Definition at line 58 of file prep.c.

59 {
60  *Width = 80;
61  *Height = 25;
62  *Depth = 16;
63 }
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:656

Referenced by PpcPrepInit().

◆ PpcPrepVideoSetDisplayMode()

VIDEODISPLAYMODE PpcPrepVideoSetDisplayMode ( char DisplayMode,
BOOLEAN  Init 
)

Definition at line 53 of file prep.c.

54 {
55  return VideoTextMode;
56 }

Referenced by PpcPrepInit().

◆ sync()

void sync ( void  )

Definition at line 9 of file prep.c.

9 { __asm__("eieio\n\tsync"); }
__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")

Referenced by ide_bsy(), ide_drq(), ide_rdy(), ide_setup(), pci_read(), pci_write(), PpcPrepPutChar(), and ios_base::sync_with_stdio().

Variable Documentation

◆ mem_range_end

int mem_range_end

Definition at line 167 of file mach.c.

Referenced by PpcGetMemoryMap(), PpcInitializeMmu(), and PpcPrepGetMemoryMap().

◆ prep_serial

int prep_serial = 0x800003f8

Definition at line 6 of file prep.c.

Referenced by PpcPrepConsGetCh(), and PpcPrepPutChar().