Author: evb Date: Tue Feb 2 18:21:19 2010 New Revision: 45379
URL: http://svn.reactos.org/svn/reactos?rev=45379&view=rev Log: - Change ARM loading architecture to match EFI/Firmware model. LLB provides "firmware" routines, FreeLDR obtains "firmware" routines from the ARM block, and sets them as the Machine VTable. All board-specific FreeLDR code gone now. - Start work on UI. Serial output is now only for debugging, not usual console. - Need PL045 Keyboard code to handle KbHit/GetCh. - Have PL011 code ready for MachVideo routines, coming soon... - Start stub of environment functions.
Added: trunk/reactos/boot/armllb/envir.c (with props) trunk/reactos/boot/armllb/fw.c (with props) trunk/reactos/boot/armllb/inc/fw.h (with props) Removed: trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c trunk/reactos/boot/freeldr/freeldr/arch/arm/omapuart.c trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c Modified: trunk/reactos/boot/armllb/armllb.rbuild trunk/reactos/boot/armllb/crtsupp.c trunk/reactos/boot/armllb/hw/versatile/hwinfo.c trunk/reactos/boot/armllb/hw/video.c trunk/reactos/boot/armllb/inc/hw.h trunk/reactos/boot/armllb/inc/osloader.h trunk/reactos/boot/armllb/inc/precomp.h trunk/reactos/boot/armllb/inc/video.h trunk/reactos/boot/armllb/main.c trunk/reactos/boot/armllb/os/loader.c trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c trunk/reactos/boot/freeldr/freeldr/freeldr.rbuild trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h
Modified: trunk/reactos/boot/armllb/armllb.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/armllb.rbuild?r... ============================================================================== --- trunk/reactos/boot/armllb/armllb.rbuild [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/armllb.rbuild [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -21,6 +21,8 @@ <file first="true">boot.s</file> <file>main.c</file> <file>crtsupp.c</file> + <file>envir.c</file> + <file>fw.c</file> <directory name="hw"> <file>serial.c</file> <file>video.c</file>
Modified: trunk/reactos/boot/armllb/crtsupp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/crtsupp.c?rev=4... ============================================================================== --- trunk/reactos/boot/armllb/crtsupp.c [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/crtsupp.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -11,11 +11,11 @@ int putchar(int c) { - /* Write to the serial port */ + /* Write to the screen */ + LlbVideoPutChar(c); + + /* For DEBUGGING ONLY */ LlbSerialPutChar(c); - - /* Write to the screen too */ - LlbVideoPutChar(c); return 0; }
@@ -32,13 +32,9 @@ unsigned int i; char printbuffer[1024];
- va_start (args, fmt); - - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - i = vsprintf (printbuffer, fmt, args); - va_end (args); + va_start(args, fmt); + i = vsprintf(printbuffer, fmt, args); + va_end(args);
/* Print the string */ return puts(printbuffer);
Added: trunk/reactos/boot/armllb/envir.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/envir.c?rev=453... ============================================================================== --- trunk/reactos/boot/armllb/envir.c (added) +++ trunk/reactos/boot/armllb/envir.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -1,0 +1,20 @@ +/* + * PROJECT: ReactOS Boot Loader + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/armllb/envir.c + * PURPOSE: LLB Environment Variable Routines + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +#include "precomp.h" + +PCHAR +NTAPI +LlbEnvRead(IN PCHAR ValueName) +{ + /* FIXME: HACK */ + return "RAMDISK"; +} + +/* EOF */ +
Propchange: trunk/reactos/boot/armllb/envir.c ------------------------------------------------------------------------------ svn:eol-style = native
Added: trunk/reactos/boot/armllb/fw.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/fw.c?rev=45379&... ============================================================================== --- trunk/reactos/boot/armllb/fw.c (added) +++ trunk/reactos/boot/armllb/fw.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -1,0 +1,36 @@ +/* + * PROJECT: ReactOS Boot Loader + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/armllb/fw.c + * PURPOSE: LLB Firmware Routines (accessible by OS Loader) + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +#include "precomp.h" + +VOID +LlbFwPutChar(INT Ch) +{ + /* Just call directly the video function */ + LlbVideoPutChar(Ch); + + /* DEBUG ONLY */ + LlbSerialPutChar(Ch); +} + +BOOLEAN +LlbFwKbHit(VOID) +{ + /* Not yet implemented */ + return FALSE; +} + +INT +LlbFwGetCh(VOID) +{ + /* Not yet implemented */ + while (TRUE); + return 0; +} + +/* EOF */
Propchange: trunk/reactos/boot/armllb/fw.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/boot/armllb/hw/versatile/hwinfo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/hw/versatile/hw... ============================================================================== --- trunk/reactos/boot/armllb/hw/versatile/hwinfo.c [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/hw/versatile/hwinfo.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -47,15 +47,4 @@ LlbAllocateMemoryEntry(BiosMemoryReserved, 0x10000000, 128 * 1024 * 1024); }
-// -// hwenv.c? or environment.c? or both? -// -PCHAR -NTAPI -LlbHwEnvRead(IN PCHAR Option) -{ - /* HACKFIX */ - return "RAMDISK"; -} - /* EOF */
Modified: trunk/reactos/boot/armllb/hw/video.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/hw/video.c?rev=... ============================================================================== --- trunk/reactos/boot/armllb/hw/video.c [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/hw/video.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -268,6 +268,28 @@ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, };
+#if 0 +USHORT ColorPalette[16] = +{ + RGB565(0x00, 0x00, 0x00), + RGB565(0x00, 0x00, 0xAA), + RGB565(0x00, 0xAA, 0x00), + RGB565(0x00, 0xAA, 0xAA), + RGB565(0xAA, 0x00, 0x00), + RGB565(0xAA, 0x00, 0xAA), + RGB565(0xAA, 0x55, 0x00), + RGB565(0xAA, 0xAA, 0xAA), + RGB565(0x55, 0x55, 0x55), + RGB565(0x55, 0x55, 0xFF), + RGB565(0x55, 0xFF, 0x55), + RGB565(0x55, 0xFF, 0xFF), + RGB565(0xFF, 0x55, 0x55), + RGB565(0xFF, 0x55, 0xFF), + RGB565(0xFF, 0xFF, 0x55), + RGB565(0xFF, 0xFF, 0xFF), +}; +#endif + ULONG ScreenCursor;
VOID @@ -312,7 +334,7 @@
VOID NTAPI -LlbVideoClearScreen(VOID) +LlbVideoClearScreen(IN BOOLEAN OsLoader) { ULONG ScreenSize, p; ULONG BackColor; @@ -323,8 +345,17 @@ ScreenCursor = 0;
/* Backcolor on this machine */ - BackColor = LlbHwVideoCreateColor(14, 0, 82); - BackColor = (BackColor << 16) | BackColor; + if (OsLoader) + { + /* Black */ + BackColor = 0; + } + else + { + /* Deep blue */ + BackColor = LlbHwVideoCreateColor(14, 0, 82); + BackColor = (BackColor << 16) | BackColor; + }
/* Screen size on this machine */ ScreenSize = LlbHwGetScreenWidth() * LlbHwGetScreenHeight(); @@ -369,3 +400,4 @@ }
/* EOF */ +
Added: trunk/reactos/boot/armllb/inc/fw.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/fw.h?rev=45... ============================================================================== --- trunk/reactos/boot/armllb/inc/fw.h (added) +++ trunk/reactos/boot/armllb/inc/fw.h [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -1,0 +1,24 @@ +/* + * PROJECT: ReactOS Boot Loader + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/armllb/inc/fw.h + * PURPOSE: LLB Firmware Functions + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +VOID +LlbFwPutChar( + INT Ch +); + +BOOLEAN +LlbFwKbHit( + VOID +); + +INT +LlbFwGetCh( + VOID +); + +/* EOF */
Propchange: trunk/reactos/boot/armllb/inc/fw.h ------------------------------------------------------------------------------ svn:eol-style = native
Propchange: trunk/reactos/boot/armllb/inc/fw.h ------------------------------------------------------------------------------ svn:executable = *
Modified: trunk/reactos/boot/armllb/inc/hw.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/hw.h?rev=45... ============================================================================== --- trunk/reactos/boot/armllb/inc/hw.h [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/inc/hw.h [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -92,12 +92,6 @@ VOID );
-PCHAR -NTAPI -LlbHwEnvRead( - IN PCHAR Option -); - #ifdef _VERSATILE_ #include "versa.h" #elif _OMAP3_
Modified: trunk/reactos/boot/armllb/inc/osloader.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/osloader.h?... ============================================================================== --- trunk/reactos/boot/armllb/inc/osloader.h [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/inc/osloader.h [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -14,6 +14,7 @@ IN PVOID BoardInit );
+#ifndef __REGISTRY_H // // Type of memory detected by LLB // @@ -35,12 +36,13 @@ ULONG Type; ULONG Reserved; } BIOS_MEMORY_MAP, *PBIOS_MEMORY_MAP; +#endif
// // Information sent from LLB to OS Loader // #define ARM_BOARD_CONFIGURATION_MAJOR_VERSION 1 -#define ARM_BOARD_CONFIGURATION_MINOR_VERSION 1 +#define ARM_BOARD_CONFIGURATION_MINOR_VERSION 2 typedef struct _ARM_BOARD_CONFIGURATION_BLOCK { ULONG MajorVersion; @@ -52,6 +54,9 @@ ULONG MemoryMapEntryCount; PBIOS_MEMORY_MAP MemoryMap; CHAR CommandLine[256]; + PVOID ConsPutChar; + PVOID ConsKbHit; + PVOID ConsGetCh; } ARM_BOARD_CONFIGURATION_BLOCK, *PARM_BOARD_CONFIGURATION_BLOCK;
VOID @@ -92,4 +97,10 @@ IN PCHAR CommandLine );
+PCHAR +NTAPI +LlbEnvRead( + IN PCHAR Option +); + /* EOF */
Modified: trunk/reactos/boot/armllb/inc/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/precomp.h?r... ============================================================================== --- trunk/reactos/boot/armllb/inc/precomp.h [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/inc/precomp.h [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -12,6 +12,7 @@ #include "machtype.h" #include "osloader.h" #include "hw.h" +#include "fw.h" #include "serial.h" #include "video.h"
Modified: trunk/reactos/boot/armllb/inc/video.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/video.h?rev... ============================================================================== --- trunk/reactos/boot/armllb/inc/video.h [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/inc/video.h [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -9,7 +9,7 @@ VOID NTAPI LlbVideoClearScreen( - VOID + IN BOOLEAN OsLoader );
VOID
Modified: trunk/reactos/boot/armllb/main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/main.c?rev=4537... ============================================================================== --- trunk/reactos/boot/armllb/main.c [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/main.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -15,7 +15,7 @@ LlbHwInitialize();
/* Clean up the screen */ - LlbVideoClearScreen(); + LlbVideoClearScreen(FALSE);
/* Print header */ printf("ReactOS ARM Low-Level Boot Loader [" __DATE__ " "__TIME__ "]\n"); @@ -25,4 +25,18 @@ while (TRUE); }
+VOID +DbgPrint(const char *fmt, ...) +{ + va_list args; + unsigned int i; + char Buffer[1024]; + + va_start(args, fmt); + i = vsprintf(Buffer, fmt, args); + va_end(args); + + while (*Buffer) LlbSerialPutChar(*Buffer); +} + /* EOF */
Modified: trunk/reactos/boot/armllb/os/loader.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/os/loader.c?rev... ============================================================================== --- trunk/reactos/boot/armllb/os/loader.c [iso-8859-1] (original) +++ trunk/reactos/boot/armllb/os/loader.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -69,6 +69,11 @@
/* Now load the memory map */ ArmBlock.MemoryMap = MemoryMap; + + /* Write firmware callbacks */ + ArmBlock.ConsPutChar = LlbFwPutChar; + ArmBlock.ConsKbHit = LlbFwKbHit; + ArmBlock.ConsGetCh = LlbFwGetCh; }
VOID @@ -89,7 +94,7 @@ PCHAR BootDevice;
/* Read the current boot device */ - BootDevice = LlbHwEnvRead("boot-device"); + BootDevice = LlbEnvRead("boot-device"); printf("Loading OS Loader from: %s...\n", BootDevice); if (!strcmp(BootDevice, "NAND")) { @@ -109,7 +114,7 @@ { //todo } - printf("OS Loader loaded at 0x%p...JUMP!\n", LoaderInit); + printf("OS Loader loaded at 0x%p...JUMP!\n\n\n\n\n", LoaderInit); }
VOID
Removed: trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/a... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/arm/ferouart.c (removed) @@ -1,130 +1,0 @@ -/* - * PROJECT: ReactOS Boot Loader - * LICENSE: BSD - See COPYING.ARM in the top level directory - * FILE: boot/freeldr/arch/arm/ferouart.c - * PURPOSE: Implements code for Feroceon boards using the 16550 UART - * PROGRAMMERS: ReactOS Portable Systems Group - */ - -/* INCLUDES *******************************************************************/ - -#include <freeldr.h> - -/* GLOBALS ********************************************************************/ - -// -// UART Registers -// -#define UART0_RBR (ArmBoardBlock->UartRegisterBase + 0x00) -#define UART0_THR UART0_RBR -#define UART0_IER (ArmBoardBlock->UartRegisterBase + 0x04) -#define UART0_FCR (ArmBoardBlock->UartRegisterBase + 0x08) -#define UART0_LCR (ArmBoardBlock->UartRegisterBase + 0x0C) -#define UART0_MCR (ArmBoardBlock->UartRegisterBase + 0x10) -#define UART0_LSR (ArmBoardBlock->UartRegisterBase + 0x14) -#define UART0_MSR (ArmBoardBlock->UartRegisterBase + 0x18) -#define UART0_SCR (ArmBoardBlock->UartRegisterBase + 0x1C) - -// -// When we enable the divisor latch -// -#define UART0_DLL UART0_RBR -#define UART0_DLM UART0_IER - -// -// FCR Values -// -#define FCR_FIFO_EN 0x01 -#define FCR_RXSR 0x02 -#define FCR_TXSR 0x04 - -// -// LCR Values -// -#define LCR_WLS_8 0x03 -#define LCR_1_STB 0x00 -#define LCR_DIVL_EN 0x80 -#define LCR_NO_PAR 0x00 - -// -// LSR Values -// -#define LSR_DR 0x01 -#define LSR_THRE 0x20 - -/* FUNCTIONS ******************************************************************/ - -VOID -ArmFeroSerialInit(IN ULONG Baudrate) -{ - ULONG BaudClock; - - // - // Calculate baudrate clock divider to set the baud rate - // - BaudClock = (ArmBoardBlock->ClockRate / 16) / Baudrate; - - // - // Disable interrupts - // - WRITE_REGISTER_UCHAR(UART0_IER, 0); - - // - // Set the baud rate to 115200 bps - // - WRITE_REGISTER_UCHAR(UART0_LCR, LCR_DIVL_EN); - WRITE_REGISTER_UCHAR(UART0_DLL, BaudClock); - WRITE_REGISTER_UCHAR(UART0_DLM, (BaudClock >> 8) & 0xFF); - - // - // Set 8 bits for data, 1 stop bit, no parity - // - WRITE_REGISTER_UCHAR(UART0_LCR, LCR_WLS_8 | LCR_1_STB | LCR_NO_PAR); - - // - // Clear and enable FIFO - // - WRITE_REGISTER_UCHAR(UART0_FCR, FCR_FIFO_EN | FCR_RXSR | FCR_TXSR); -} - -VOID -ArmFeroPutChar(IN INT Char) -{ - // - // Properly support new-lines - // - if (Char == '\n') ArmFeroPutChar('\r'); - - // - // Wait for ready - // - while ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_THRE) == 0); - - // - // Send the character - // - WRITE_REGISTER_UCHAR(UART0_THR, Char); -} - -INT -ArmFeroGetCh(VOID) -{ - // - // Wait for ready - // - while ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_DR) == 0); - - // - // Read the character - // - return READ_REGISTER_UCHAR(UART0_RBR); -} - -BOOLEAN -ArmFeroKbHit(VOID) -{ - // - // Return if something is ready - // - return ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_DR) != 0); -}
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/a... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -1607,6 +1607,7 @@ // // Initialize the page directory // + while (TRUE); ArmSetupPageDirectory();
//
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/a... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/arm/macharm.c [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -9,6 +9,7 @@ /* INCLUDES *******************************************************************/
#include <freeldr.h> +#define RGB565(r, g, b) (((r >> 3) << 11)| ((g >> 2) << 5)| ((b >> 3) << 0))
/* GLOBALS ********************************************************************/
@@ -33,7 +34,7 @@ ArmBoardBlock = BootContext;
// - // Let's make sure we understand the boot-loader + // Let's make sure we understand the LLB // ASSERT(ArmBoardBlock->MajorVersion == ARM_BOARD_CONFIGURATION_MAJOR_VERSION); ASSERT(ArmBoardBlock->MinorVersion == ARM_BOARD_CONFIGURATION_MINOR_VERSION); @@ -133,32 +134,21 @@ // switch (ArmBoardBlock->BoardType) { - // - // Check for Feroceon-base boards - // + // + // Check for Feroceon-base boards + // case MACH_TYPE_FEROCEON: - - // - // These boards use a UART16550. Set us up for 115200 bps - // - ArmFeroSerialInit(115200); - MachVtbl.ConsPutChar = ArmFeroPutChar; - MachVtbl.ConsKbHit = ArmFeroKbHit; - MachVtbl.ConsGetCh = ArmFeroGetCh; break;
- // - // Check for ARM Versatile PB boards - // + // + // Check for ARM Versatile PB boards + // case MACH_TYPE_VERSATILE_PB:
- // - // These boards use a PrimeCell UART (PL011) - // - ArmVersaSerialInit(115200); - MachVtbl.ConsPutChar = ArmVersaPutChar; - MachVtbl.ConsKbHit = ArmVersaKbHit; - MachVtbl.ConsGetCh = ArmVersaGetCh; + /* Copy Machine Routines from Firmware Table */ + MachVtbl.ConsPutChar = ArmBoardBlock->ConsPutChar; + MachVtbl.ConsKbHit = ArmBoardBlock->ConsKbHit; + MachVtbl.ConsGetCh = ArmBoardBlock->ConsGetCh; break;
// @@ -166,14 +156,6 @@ // For now that means only Beagle, but ZOOM and others should be ok too // case MACH_TYPE_OMAP3_BEAGLE: - - // - // These boards use a UART16550 - // - ArmOmap3SerialInit(115200); - MachVtbl.ConsPutChar = ArmOmap3PutChar; - MachVtbl.ConsKbHit = ArmOmap3KbHit; - MachVtbl.ConsGetCh = ArmOmap3GetCh; break;
default: @@ -204,5 +186,5 @@ // We can now print to the console // TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString()); - TuiPrintf("Bootargs: %s\n", CommandLine); + TuiPrintf("Bootargs: %s\n\n", CommandLine); }
Removed: trunk/reactos/boot/freeldr/freeldr/arch/arm/omapuart.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/a... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/arm/omapuart.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/arm/omapuart.c (removed) @@ -1,162 +1,0 @@ -/* - * PROJECT: ReactOS Boot Loader - * LICENSE: BSD - See COPYING.ARM in the top level directory - * FILE: boot/freeldr/arch/arm/omapuart.c - * PURPOSE: Implements code for TI OMAP3 boards using the 16550 UART - * PROGRAMMERS: ReactOS Portable Systems Group - */ - -/* INCLUDES *******************************************************************/ - -#include <freeldr.h> - -/* GLOBALS ********************************************************************/ - -// -// UART Registers -// -#define UART0_RHR (ArmBoardBlock->UartRegisterBase + 0x00) -#define UART0_THR UART0_RHR -#define UART0_IER (ArmBoardBlock->UartRegisterBase + 0x04) -#define UART0_FCR (ArmBoardBlock->UartRegisterBase + 0x08) -#define UART0_LCR (ArmBoardBlock->UartRegisterBase + 0x0C) -#define UART0_MCR (ArmBoardBlock->UartRegisterBase + 0x10) -#define UART0_LSR (ArmBoardBlock->UartRegisterBase + 0x14) -#define UART0_MDR1 (ArmBoardBlock->UartRegisterBase + 0x20) - -// -// When we enable the divisor latch -// -#define UART0_DLL UART0_RHR -#define UART0_DLH UART0_IER - -// -// FCR Values -// -#define FCR_FIFO_EN 0x01 -#define FCR_RXSR 0x02 -#define FCR_TXSR 0x04 - -// -// LCR Values -// -#define LCR_WLS_8 0x03 -#define LCR_1_STB 0x00 -#define LCR_DIVL_EN 0x80 -#define LCR_NO_PAR 0x00 - -// -// LSR Values -// -#define LSR_DR 0x01 -#define LSR_THRE 0x20 - -// -// MCR Values -// -#define MCR_DTR 0x01 -#define MCR_RTS 0x02 - -// -// MDR1 Modes -// -#define MDR1_UART16X 1 -#define MDR1_SIR 2 -#define MDR1_UART16X_AUTO_BAUD 3 -#define MDR1_UART13X 4 -#define MDR1_MIR 5 -#define MDR1_FIR 6 -#define MDR1_CIR 7 -#define MDR1_DISABLE 8 - -/* FUNCTIONS ******************************************************************/ - -VOID -ArmOmap3SerialInit(IN ULONG Baudrate) -{ - ULONG BaudClock; - - // - // Calculate baudrate clock divider to set the baud rate - // - BaudClock = (ArmBoardBlock->ClockRate / 16) / Baudrate; - - // - // Disable serial port - // - WRITE_REGISTER_UCHAR(UART0_MDR1, MDR1_DISABLE); - - // - // Disable interrupts - // - WRITE_REGISTER_UCHAR(UART0_IER, 0); - - // - // Set the baud rate to 115200 bps - // - WRITE_REGISTER_UCHAR(UART0_LCR, LCR_DIVL_EN); - WRITE_REGISTER_UCHAR(UART0_DLL, BaudClock); - WRITE_REGISTER_UCHAR(UART0_DLH, (BaudClock >> 8) & 0xFF); - - // - // Setup loopback - // - WRITE_REGISTER_UCHAR(UART0_MCR, MCR_DTR | MCR_RTS); - - // - // Set 8 bits for data, 1 stop bit, no parity - // - WRITE_REGISTER_UCHAR(UART0_LCR, LCR_WLS_8 | LCR_1_STB | LCR_NO_PAR); - - // - // Clear and enable FIFO - // - WRITE_REGISTER_UCHAR(UART0_FCR, FCR_FIFO_EN | FCR_RXSR | FCR_TXSR); - - // - // Enable serial port - // - WRITE_REGISTER_UCHAR(UART0_MDR1, MDR1_UART16X); -} - -VOID -ArmOmap3PutChar(IN INT Char) -{ - // - // Properly support new-lines - // - if (Char == '\n') ArmOmap3PutChar('\r'); - - // - // Wait for ready - // - while ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_THRE) == 0); - - // - // Send the character - // - WRITE_REGISTER_UCHAR(UART0_THR, Char); -} - -INT -ArmOmap3GetCh(VOID) -{ - // - // Wait for ready - // - while ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_DR) == 0); - - // - // Read the character - // - return READ_REGISTER_UCHAR(UART0_RHR); -} - -BOOLEAN -ArmOmap3KbHit(VOID) -{ - // - // Return if something is ready - // - return ((READ_REGISTER_UCHAR(UART0_LSR) & LSR_DR) != 0); -}
Removed: trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/a... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/arm/versuart.c (removed) @@ -1,132 +1,0 @@ -/* - * PROJECT: ReactOS Boot Loader - * LICENSE: BSD - See COPYING.ARM in the top level directory - * FILE: boot/freeldr/arch/arm/versuart.c - * PURPOSE: Implements code for Versatile boards using the PL011 UART - * PROGRAMMERS: ReactOS Portable Systems Group - */ - -/* INCLUDES *******************************************************************/ - -#include <freeldr.h> - -/* GLOBALS ********************************************************************/ - -// -// UART Registers -// -#define UART_PL01x_DR (ArmBoardBlock->UartRegisterBase + 0x00) -#define UART_PL01x_RSR (ArmBoardBlock->UartRegisterBase + 0x04) -#define UART_PL01x_ECR (ArmBoardBlock->UartRegisterBase + 0x04) -#define UART_PL01x_FR (ArmBoardBlock->UartRegisterBase + 0x18) -#define UART_PL011_IBRD (ArmBoardBlock->UartRegisterBase + 0x24) -#define UART_PL011_FBRD (ArmBoardBlock->UartRegisterBase + 0x28) -#define UART_PL011_LCRH (ArmBoardBlock->UartRegisterBase + 0x2C) -#define UART_PL011_CR (ArmBoardBlock->UartRegisterBase + 0x30) -#define UART_PL011_IMSC (ArmBoardBlock->UartRegisterBase + 0x38) - -// -// LCR Values -// -#define UART_PL011_LCRH_WLEN_8 0x60 -#define UART_PL011_LCRH_FEN 0x10 - -// -// FCR Values -// -#define UART_PL011_CR_UARTEN 0x01 -#define UART_PL011_CR_TXE 0x100 -#define UART_PL011_CR_RXE 0x200 - -// -// LSR Values -// -#define UART_PL01x_FR_RXFE 0x10 -#define UART_PL01x_FR_TXFF 0x20 - -/* FUNCTIONS ******************************************************************/ - -VOID -ArmVersaSerialInit(IN ULONG Baudrate) -{ - ULONG Divider, Remainder, Fraction; - - // - // Calculate baudrate clock divider and remainder - // - Divider = ArmBoardBlock->ClockRate / (16 * Baudrate); - Remainder = ArmBoardBlock->ClockRate % (16 * Baudrate); - - // - // Calculate the fractional part - // - Fraction = (8 * Remainder / Baudrate) >> 1; - Fraction += (8 * Remainder / Baudrate) & 1; - - // - // Disable interrupts - // - WRITE_REGISTER_ULONG(UART_PL011_CR, 0); - - // - // Set the baud rate to 115200 bps - // - WRITE_REGISTER_ULONG(UART_PL011_IBRD, Divider); - WRITE_REGISTER_ULONG(UART_PL011_FBRD, Fraction); - - // - // Set 8 bits for data, 1 stop bit, no parity, FIFO enabled - // - WRITE_REGISTER_ULONG(UART_PL011_LCRH, - UART_PL011_LCRH_WLEN_8 | UART_PL011_LCRH_FEN); - - // - // Clear and enable FIFO - // - WRITE_REGISTER_ULONG(UART_PL011_CR, - UART_PL011_CR_UARTEN | - UART_PL011_CR_TXE | - UART_PL011_CR_RXE); -} - -VOID -ArmVersaPutChar(IN INT Char) -{ - // - // Properly support new-lines - // - if (Char == '\n') ArmVersaPutChar('\r'); - - // - // Wait for ready - // - while ((READ_REGISTER_ULONG(UART_PL01x_FR) & UART_PL01x_FR_TXFF) != 0); - - // - // Send the character - // - WRITE_REGISTER_ULONG(UART_PL01x_DR, Char); -} - -INT -ArmVersaGetCh(VOID) -{ - // - // Wait for ready - // - while ((READ_REGISTER_ULONG(UART_PL01x_FR) & UART_PL01x_FR_RXFE) != 0); - - // - // Read the character - // - return READ_REGISTER_ULONG(UART_PL01x_DR); -} - -BOOLEAN -ArmVersaKbHit(VOID) -{ - // - // Return if something is ready - // - return ((READ_REGISTER_ULONG(UART_PL01x_FR) & UART_PL01x_FR_RXFE) == 0); -}
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freeld... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr.rbuild [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr.rbuild [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -32,8 +32,14 @@ <library>rtl</library> <library>libcntpr</library> <group linkerset="ld"> + <linkerflag>-static</linkerflag> <linkerflag>-lgcc</linkerflag> - <linkerflag>-Wl,--image-base=0x80FFF000</linkerflag> + <if property="SARCH" value="omap3"> + <linkerflag>-Wl,--image-base=0x80FFF000</linkerflag> + </if> + <if property="SARCH" value="versatile"> + <linkerflag>-Wl,--image-base=0x007FF000</linkerflag> + </if> </group> </module> </if>
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freeld... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -73,11 +73,8 @@ <directory name="arm"> <if property="ARCH" value="arm"> <file first="true">boot.s</file> - <file>ferouart.c</file> <file>loader.c</file> <file>macharm.c</file> - <file>omapuart.c</file> - <file>versuart.c</file> </if> </directory>
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h [iso-8859-1] Tue Feb 2 18:21:19 2010 @@ -13,41 +13,8 @@ #include "../../reactos/registry.h" #endif
-// -// Marvell Feroceon-based SoC: -// Buffalo Linkstation, KuroBox Pro, D-Link DS323 and others -// -#define MACH_TYPE_FEROCEON 526 - -// -// ARM Versatile PB: -// qemu-system-arm -M versatilepb, RealView Development Boards and others -// -#define MACH_TYPE_VERSATILE_PB 387 - -// -// TI Beagle Board, OMAP3530 SoC -// qemu-system-arm -M beagle, Beagle Board -// -#define MACH_TYPE_OMAP3_BEAGLE 1546 - -// -// Compatible boot-loaders should return us this information -// -#define ARM_BOARD_CONFIGURATION_MAJOR_VERSION 1 -#define ARM_BOARD_CONFIGURATION_MINOR_VERSION 1 -typedef struct _ARM_BOARD_CONFIGURATION_BLOCK -{ - ULONG MajorVersion; - ULONG MinorVersion; - ULONG BoardType; - ULONG ClockRate; - ULONG TimerRegisterBase; - ULONG UartRegisterBase; - ULONG MemoryMapEntryCount; - PBIOS_MEMORY_MAP MemoryMap; - CHAR CommandLine[256]; -} ARM_BOARD_CONFIGURATION_BLOCK, *PARM_BOARD_CONFIGURATION_BLOCK; +#include "../../../../../armllb/inc/osloader.h" +#include "../../../../../armllb/inc/machtype.h"
// // Static heap for ARC Hardware Component Tree @@ -79,42 +46,6 @@ OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey );
-VOID -ArmFeroSerialInit(IN ULONG Baudrate); - -VOID -ArmFeroPutChar(IN INT Char); - -INT -ArmFeroGetCh(VOID); - -BOOLEAN -ArmFeroKbHit(VOID); - -VOID -ArmOmap3SerialInit(IN ULONG Baudrate); - -VOID -ArmOmap3PutChar(IN INT Char); - -INT -ArmOmap3GetCh(VOID); - -BOOLEAN -ArmOmap3KbHit(VOID); - -VOID -ArmVersaSerialInit(IN ULONG Baudrate); - -VOID -ArmVersaPutChar(IN INT Char); - -INT -ArmVersaGetCh(VOID); - -BOOLEAN -ArmVersaKbHit(VOID); - extern PARM_BOARD_CONFIGURATION_BLOCK ArmBoardBlock;
#endif