ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

prep.c
Go to the documentation of this file.
00001 #include "freeldr.h"
00002 #include "machine.h"
00003 #include "ppcmmu/mmu.h"
00004 #include "prep.h"
00005 
00006 int prep_serial = 0x800003f8;
00007 extern int mem_range_end;
00008 
00009 void sync() { __asm__("eieio\n\tsync"); }
00010 
00011 /* Simple serial */
00012 
00013 void PpcPrepPutChar( int ch ) {
00014     if( ch == 0x0a ) {
00015     SetPhysByte(prep_serial, 0x0d);
00016     sync();
00017     }
00018     SetPhysByte(prep_serial, ch);
00019     sync();
00020 }
00021 
00022 BOOLEAN PpcPrepDiskReadLogicalSectors
00023 ( ULONG DriveNumber, ULONGLONG SectorNumber,
00024   ULONG SectorCount, PVOID Buffer ) {
00025     int secct;
00026 
00027     for(secct = 0; secct < SectorCount; secct++)
00028     {
00029     ide_seek(&ide1_desc, SectorNumber + secct, 0);
00030     ide_read(&ide1_desc, ((PCHAR)Buffer) + secct * 512, 512);
00031     }
00032     /* Never give up! */
00033     return TRUE;
00034 }
00035 
00036 BOOLEAN PpcPrepConsKbHit()
00037 {
00038     return 1;
00039     //return GetPhysByte(prep_serial+5) & 1;
00040 }
00041 
00042 int PpcPrepConsGetCh()
00043 {
00044     while(!PpcPrepConsKbHit());
00045     return GetPhysByte(prep_serial);
00046 }
00047 
00048 void PpcPrepVideoClearScreen(UCHAR Attr)
00049 {
00050     printf("\033c");
00051 }
00052 
00053 VIDEODISPLAYMODE PpcPrepVideoSetDisplayMode( char *DisplayMode, BOOLEAN Init )
00054 {
00055     return VideoTextMode;
00056 }
00057 
00058 void PpcPrepVideoGetDisplaySize( PULONG Width, PULONG Height, PULONG Depth )
00059 {
00060     *Width = 80;
00061     *Height = 25;
00062     *Depth = 16;
00063 }
00064 
00065 void PpcPrepVideoPrepareForReactOS(BOOLEAN setup)
00066 {
00067 }
00068 
00069 VOID PpcInitializeMmu(int max);
00070 
00071 ULONG PpcPrepGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap,
00072                ULONG MaxMemoryMapSize )
00073 {
00074     // Probe memory
00075     paddr_t physAddr;
00076     register int oldStore = 0, newStore = 0, change = 0, oldmsr;
00077 
00078     __asm__("mfmsr %0\n" : "=r" (oldmsr));
00079     change = oldmsr & 0x6fff;
00080     __asm__("mtmsr %0\n" : : "r" (change));
00081 
00082     // Find the last ram address in physical space ... this bypasses mapping
00083     // but could run into non-ram objects right above ram.  Usually systems
00084     // aren't designed like that though.
00085     for (physAddr = 0x40000, change = newStore; 
00086          (physAddr < 0x80000000) && (change == newStore); 
00087          physAddr += 1 << 12)
00088     {
00089         oldStore = GetPhys(physAddr);
00090         newStore = (physAddr & 0x1000) ? 0x55aa55aa : 0xaa55aa55;
00091         SetPhys(physAddr, newStore);
00092         change = GetPhys(physAddr);
00093         SetPhys(physAddr, oldStore);
00094     }
00095     // Back off by one page
00096     physAddr -= 0x1000;
00097     BiosMemoryMap[0].BaseAddress = 0x30000; // End of ppcmmu
00098     BiosMemoryMap[0].Type = BiosMemoryUsable;
00099     BiosMemoryMap[0].Length = physAddr - BiosMemoryMap[0].BaseAddress;
00100 
00101     __asm__("mtmsr %0\n" : : "r" (oldmsr));
00102 
00103     mem_range_end = physAddr;
00104 
00105     printf("Actual RAM: %d Mb\n", physAddr >> 20);
00106     return 1;
00107 }
00108 
00109 /* Most PReP hardware is in standard locations, based on the corresponding 
00110  * hardware on PCs. */
00111 PCONFIGURATION_COMPONENT_DATA PpcPrepHwDetect() {
00112   PCONFIGURATION_COMPONENT_DATA SystemKey;
00113 
00114   /* Create the 'System' key */
00115   FldrCreateSystemKey(&SystemKey);
00116 
00117   printf("DetectHardware() Done\n");
00118   return SystemKey;
00119 }
00120 
00121 VOID
00122 PpcPrepHwIdle(VOID)
00123 {
00124     /* UNIMPLEMENTED */
00125 }
00126 
00127 void PpcPrepInit()
00128 {
00129     MachVtbl.ConsPutChar = PpcPrepPutChar;
00130 
00131     printf("Serial on\n");
00132 
00133     ide_setup( &ide1_desc );
00134 
00135     MachVtbl.DiskReadLogicalSectors = PpcPrepDiskReadLogicalSectors;
00136 
00137     MachVtbl.ConsKbHit   = PpcPrepConsKbHit;
00138     MachVtbl.ConsGetCh   = PpcPrepConsGetCh;
00139 
00140     MachVtbl.VideoClearScreen = PpcPrepVideoClearScreen;
00141     MachVtbl.VideoSetDisplayMode = PpcPrepVideoSetDisplayMode;
00142     MachVtbl.VideoGetDisplaySize = PpcPrepVideoGetDisplaySize;
00143 
00144     MachVtbl.VideoPrepareForReactOS = PpcPrepVideoPrepareForReactOS;
00145 
00146     MachVtbl.GetMemoryMap = PpcPrepGetMemoryMap;
00147     MachVtbl.HwDetect = PpcPrepHwDetect;
00148     MachVtbl.HwIdle = PcPrepHwIdle;
00149 
00150     printf( "FreeLDR version [%s]\n", GetFreeLoaderVersionString() );
00151 
00152     BootMain( "" );
00153 }
00154 

Generated on Fri May 25 2012 04:17:11 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.