Author: hpoussin Date: Sat Oct 3 15:11:22 2009 New Revision: 43263
URL: http://svn.reactos.org/svn/reactos?rev=43263&view=rev Log: [freeldr] Code code specific to ARC emulation to its own directory
Added: trunk/reactos/boot/freeldr/freeldr/arcemul/ (with props) trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c (with props) trunk/reactos/boot/freeldr/freeldr/arcemul/time.c (with props) Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild trunk/reactos/boot/freeldr/freeldr/machine.c
Propchange: trunk/reactos/boot/freeldr/freeldr/arcemul/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Oct 3 15:11:22 2009 @@ -1,0 +1,7 @@ +GNUmakefile +*.vcproj +*.user +*.cbp +*.ncb +*.suo +*.sln
Added: trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arcemu... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c (added) +++ trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c [iso-8859-1] Sat Oct 3 15:11:22 2009 @@ -1,0 +1,176 @@ +/* + * PROJECT: ReactOS Boot Loader (FreeLDR) + * LICENSE: GPL - See COPYING in the top level directory + * FILE: boot/freeldr/freeldr/arcemul/mm.c + * PURPOSE: Routines for ARC Memory Management + * PROGRAMMERS: Hervé Poussineau hpoussin@reactos.org + */ + +/* INCLUDES *******************************************************************/ + +#include <freeldr.h> +#define NDEBUG +#include <debug.h> + +/* FUNCTIONS ******************************************************************/ + +typedef struct +{ + MEMORY_DESCRIPTOR m; + ULONG Index; + BOOLEAN GeneratedDescriptor; +} MEMORY_DESCRIPTOR_INT; +static const MEMORY_DESCRIPTOR_INT MemoryDescriptors[] = +{ +#if defined (__i386__) || defined (_M_AMD64) + { { MemoryFirmwarePermanent, 0x00, 1 }, 0, }, // realmode int vectors + { { MemoryFirmwareTemporary, 0x01, 7 }, 1, }, // freeldr stack + cmdline + { { MemoryLoadedProgram, 0x08, 0x70 }, 2, }, // freeldr image (roughly max. 0x64 pages) + { { MemorySpecialMemory, 0x78, 8 }, 3, }, // prot mode stack. BIOSCALLBUFFER + { { MemoryFirmwareTemporary, 0x80, 0x10 }, 4, }, // File system read buffer. FILESYSBUFFER + { { MemoryFirmwareTemporary, 0x90, 0x10 }, 5, }, // Disk read buffer for int 13h. DISKREADBUFFER + { { MemoryFirmwarePermanent, 0xA0, 0x60 }, 6, }, // ROM / Video + { { MemorySpecialMemory, 0xFFF, 1 }, 7, }, // unusable memory +#elif __arm__ // This needs to be done per-platform specific way + { { MemoryLoadedProgram, 0x80000, 32 }, 0, }, // X-Loader + OmapLdr + { { MemoryLoadedProgram, 0x81000, 128 }, 1, }, // FreeLDR + { { MemoryFirmwareTemporary, 0x80500, 4096 }, 2, }, // Video Buffer +#endif +}; +MEMORY_DESCRIPTOR* +ArcGetMemoryDescriptor(MEMORY_DESCRIPTOR* Current) +{ + MEMORY_DESCRIPTOR_INT* CurrentDescriptor; + BIOS_MEMORY_MAP BiosMemoryMap[32]; + static ULONG BiosMemoryMapEntryCount; + static MEMORY_DESCRIPTOR_INT BiosMemoryDescriptors[32]; + static BOOLEAN MemoryMapInitialized = FALSE; + ULONG i, j; + + // + // Check if it is the first time we're called + // + if (!MemoryMapInitialized) + { + // + // Get the machine generated memory map + // + RtlZeroMemory(BiosMemoryMap, sizeof(BIOS_MEMORY_MAP) * 32); + BiosMemoryMapEntryCount = MachVtbl.GetMemoryMap(BiosMemoryMap, + sizeof(BiosMemoryMap) / sizeof(BIOS_MEMORY_MAP)); + + // + // Copy the entries to our structure + // + for (i = 0, j = 0; i < BiosMemoryMapEntryCount; i++) + { + // + // Is it suitable memory? + // + if (BiosMemoryMap[i].Type != BiosMemoryUsable) + { + // + // No. Process next descriptor + // + continue; + } + + // + // Copy this memory descriptor + // + BiosMemoryDescriptors[j].m.MemoryType = MemoryFree; + BiosMemoryDescriptors[j].m.BasePage = BiosMemoryMap[i].BaseAddress / MM_PAGE_SIZE; + BiosMemoryDescriptors[j].m.PageCount = BiosMemoryMap[i].Length / MM_PAGE_SIZE; + BiosMemoryDescriptors[j].Index = j; + BiosMemoryDescriptors[j].GeneratedDescriptor = TRUE; + j++; + } + + // + // Remember how much descriptors we found + // + BiosMemoryMapEntryCount = j; + + // + // Mark memory map as already retrieved and initialized + // + MemoryMapInitialized = TRUE; + } + + CurrentDescriptor = CONTAINING_RECORD(Current, MEMORY_DESCRIPTOR_INT, m); + + if (Current == NULL) + { + // + // First descriptor requested + // + if (BiosMemoryMapEntryCount > 0) + { + // + // Return first generated memory descriptor + // + return &BiosMemoryDescriptors[0].m; + } + else if (sizeof(MemoryDescriptors) > 0) + { + // + // Return first fixed memory descriptor + // + return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[0].m; + } + else + { + // + // Strange case, we have no memory descriptor + // + return NULL; + } + } + else if (CurrentDescriptor->GeneratedDescriptor) + { + // + // Current entry is a generated descriptor + // + if (CurrentDescriptor->Index + 1 < BiosMemoryMapEntryCount) + { + // + // Return next generated descriptor + // + return &BiosMemoryDescriptors[CurrentDescriptor->Index + 1].m; + } + else if (sizeof(MemoryDescriptors) > 0) + { + // + // Return first fixed memory descriptor + // + return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[0].m; + } + else + { + // + // No fixed memory descriptor; end of memory map + // + return NULL; + } + } + else + { + // + // Current entry is a fixed descriptor + // + if (CurrentDescriptor->Index + 1 < sizeof(MemoryDescriptors) / sizeof(MemoryDescriptors[0])) + { + // + // Return next fixed descriptor + // + return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[CurrentDescriptor->Index + 1].m; + } + else + { + // + // No more fixed memory descriptor; end of memory map + // + return NULL; + } + } +}
Propchange: trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/boot/freeldr/freeldr/arcemul/time.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arcemu... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arcemul/time.c (added) +++ trunk/reactos/boot/freeldr/freeldr/arcemul/time.c [iso-8859-1] Sat Oct 3 15:11:22 2009 @@ -1,0 +1,30 @@ +/* + * PROJECT: ReactOS Boot Loader (FreeLDR) + * LICENSE: GPL - See COPYING in the top level directory + * FILE: boot/freeldr/freeldr/arcemul/time.c + * PURPOSE: Routines for Time measurement + * PROGRAMMERS: Hervé Poussineau hpoussin@reactos.org + */ + +/* INCLUDES *******************************************************************/ + +#include <freeldr.h> + +/* FUNCTIONS ******************************************************************/ + +TIMEINFO* +ArcGetTime(VOID) +{ + return MachVtbl.GetTime(); +} + +ULONG +ArcGetRelativeTime(VOID) +{ + TIMEINFO* TimeInfo; + ULONG ret; + + TimeInfo = ArcGetTime(); + ret = ((TimeInfo->Hour * 24) + TimeInfo->Minute) * 60 + TimeInfo->Second; + return ret; +}
Propchange: trunk/reactos/boot/freeldr/freeldr/arcemul/time.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freeld... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild [iso-8859-1] Sat Oct 3 15:11:22 2009 @@ -11,6 +11,10 @@ <compilerflag>-fno-inline</compilerflag> <compilerflag>-fno-zero-initialized-in-bss</compilerflag> </group> + <directory name="arcemul"> + <file>mm.c</file> + <file>time.c</file> + </directory> <directory name="cache"> <file>blocklist.c</file> <file>cache.c</file>
Modified: trunk/reactos/boot/freeldr/freeldr/machine.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/machin... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/machine.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/machine.c [iso-8859-1] Sat Oct 3 15:11:22 2009 @@ -149,178 +149,6 @@ MachVtbl.PrepareForReactOS(Setup); }
-typedef struct -{ - MEMORY_DESCRIPTOR m; - ULONG Index; - BOOLEAN GeneratedDescriptor; -} MEMORY_DESCRIPTOR_INT; -static const MEMORY_DESCRIPTOR_INT MemoryDescriptors[] = -{ -#if defined (__i386__) || defined (_M_AMD64) - { { MemoryFirmwarePermanent, 0x00, 1 }, 0, }, // realmode int vectors - { { MemoryFirmwareTemporary, 0x01, 7 }, 1, }, // freeldr stack + cmdline - { { MemoryLoadedProgram, 0x08, 0x70 }, 2, }, // freeldr image (roughly max. 0x64 pages) - { { MemorySpecialMemory, 0x78, 8 }, 3, }, // prot mode stack. BIOSCALLBUFFER - { { MemoryFirmwareTemporary, 0x80, 0x10 }, 4, }, // File system read buffer. FILESYSBUFFER - { { MemoryFirmwareTemporary, 0x90, 0x10 }, 5, }, // Disk read buffer for int 13h. DISKREADBUFFER - { { MemoryFirmwarePermanent, 0xA0, 0x60 }, 6, }, // ROM / Video - { { MemorySpecialMemory, 0xFFF, 1 }, 7, }, // unusable memory -#elif __arm__ // This needs to be done per-platform specific way - { { MemoryLoadedProgram, 0x80000, 32 }, 0, }, // X-Loader + OmapLdr - { { MemoryLoadedProgram, 0x81000, 128 }, 1, }, // FreeLDR - { { MemoryFirmwareTemporary, 0x80500, 4096 }, 2, }, // Video Buffer -#endif -}; -MEMORY_DESCRIPTOR* -ArcGetMemoryDescriptor(MEMORY_DESCRIPTOR* Current) -{ - MEMORY_DESCRIPTOR_INT* CurrentDescriptor; - BIOS_MEMORY_MAP BiosMemoryMap[32]; - static ULONG BiosMemoryMapEntryCount; - static MEMORY_DESCRIPTOR_INT BiosMemoryDescriptors[32]; - static BOOLEAN MemoryMapInitialized = FALSE; - ULONG i, j; - - // - // Does machine provide an override for this function? - // - if (MachVtbl.GetMemoryDescriptor) - { - // - // Yes. Use it instead - // - return MachVtbl.GetMemoryDescriptor(Current); - } - - // - // Check if it is the first time we're called - // - if (!MemoryMapInitialized) - { - // - // Get the machine generated memory map - // - RtlZeroMemory(BiosMemoryMap, sizeof(BIOS_MEMORY_MAP) * 32); - BiosMemoryMapEntryCount = MachVtbl.GetMemoryMap(BiosMemoryMap, - sizeof(BiosMemoryMap) / sizeof(BIOS_MEMORY_MAP)); - - // - // Copy the entries to our structure - // - for (i = 0, j = 0; i < BiosMemoryMapEntryCount; i++) - { - // - // Is it suitable memory? - // - if (BiosMemoryMap[i].Type != BiosMemoryUsable) - { - // - // No. Process next descriptor - // - continue; - } - - // - // Copy this memory descriptor - // - BiosMemoryDescriptors[j].m.MemoryType = MemoryFree; - BiosMemoryDescriptors[j].m.BasePage = BiosMemoryMap[i].BaseAddress / MM_PAGE_SIZE; - BiosMemoryDescriptors[j].m.PageCount = BiosMemoryMap[i].Length / MM_PAGE_SIZE; - BiosMemoryDescriptors[j].Index = j; - BiosMemoryDescriptors[j].GeneratedDescriptor = TRUE; - j++; - } - - // - // Remember how much descriptors we found - // - BiosMemoryMapEntryCount = j; - - // - // Mark memory map as already retrieved and initialized - // - MemoryMapInitialized = TRUE; - } - - CurrentDescriptor = CONTAINING_RECORD(Current, MEMORY_DESCRIPTOR_INT, m); - - if (Current == NULL) - { - // - // First descriptor requested - // - if (BiosMemoryMapEntryCount > 0) - { - // - // Return first generated memory descriptor - // - return &BiosMemoryDescriptors[0].m; - } - else if (sizeof(MemoryDescriptors) > 0) - { - // - // Return first fixed memory descriptor - // - return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[0].m; - } - else - { - // - // Strange case, we have no memory descriptor - // - return NULL; - } - } - else if (CurrentDescriptor->GeneratedDescriptor) - { - // - // Current entry is a generated descriptor - // - if (CurrentDescriptor->Index + 1 < BiosMemoryMapEntryCount) - { - // - // Return next generated descriptor - // - return &BiosMemoryDescriptors[CurrentDescriptor->Index + 1].m; - } - else if (sizeof(MemoryDescriptors) > 0) - { - // - // Return first fixed memory descriptor - // - return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[0].m; - } - else - { - // - // No fixed memory descriptor; end of memory map - // - return NULL; - } - } - else - { - // - // Current entry is a fixed descriptor - // - if (CurrentDescriptor->Index + 1 < sizeof(MemoryDescriptors) / sizeof(MemoryDescriptors[0])) - { - // - // Return next fixed descriptor - // - return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[CurrentDescriptor->Index + 1].m; - } - else - { - // - // No more fixed memory descriptor; end of memory map - // - return NULL; - } - } -} - BOOLEAN MachDiskGetBootPath(char *BootPath, unsigned Size) { @@ -363,26 +191,6 @@ return MachVtbl.DiskGetCacheableBlockCount(DriveNumber); }
-TIMEINFO* -ArcGetTime(VOID) -{ - return MachVtbl.GetTime(); -} - -ULONG -ArcGetRelativeTime(VOID) -{ - TIMEINFO* TimeInfo; - ULONG ret; - - if (MachVtbl.GetRelativeTime) - return MachVtbl.GetRelativeTime(); - - TimeInfo = ArcGetTime(); - ret = ((TimeInfo->Hour * 24) + TimeInfo->Minute) * 60 + TimeInfo->Second; - return ret; -} - VOID MachHwDetect(VOID) {