示例#1
0
文件: hwuart.c 项目: GYGit/reactos
VOID
NTAPI
LlbHwVersaUartInitialize(VOID)
{
    ULONG Divider, Remainder, Fraction, ClockRate, Baudrate;

    /* Query peripheral rate, hardcore baudrate */
    ClockRate = LlbHwGetPClk();
    Baudrate = 115200;
    
    /* Calculate baudrate clock divider and remainder */
    Divider = ClockRate / (16 * Baudrate);
    Remainder = 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);
}
示例#2
0
VOID
NTAPI
LlbHwVersaKmiInitialize(VOID)
{
    UCHAR Divisor;
    
    /* Setup divisor and enable KMI */
    Divisor = (LlbHwGetPClk() / 8000000) - 1;
    WRITE_REGISTER_UCHAR(PL050_KMICLKDIV, Divisor);
    WRITE_REGISTER_UCHAR(PL050_KMICR, KMICR_EN);

    /* Reset PS/2 controller */
    LlbHwVersaKmiSendAndWait(PS2_O_RESET);
    if (LlbHwKbdRead() != PS2_I_BAT_OK) DbgPrint("PS/2 RESET FAILURE!\n");

    /* Send PS/2 Initialization Stream */
    LlbHwVersaKmiSendAndWait(PS2_O_DISABLE);
    LlbHwVersaKmiSendAndWait(PS2_O_SET_DEFAULT);
    LlbHwVersaKmiSendAndWait(PS2_O_SET_SCANSET);
    LlbHwVersaKmiSendAndWait(1);
    LlbHwVersaKmiSendAndWait(PS2_O_ENABLE);
}
示例#3
0
VOID
NTAPI
LlbBuildArmBlock(VOID)
{
    /* Write version number */
    ArmBlock.MajorVersion = ARM_BOARD_CONFIGURATION_MAJOR_VERSION;
    ArmBlock.MinorVersion = ARM_BOARD_CONFIGURATION_MINOR_VERSION;
    
    /* Get arch type */
    ArmBlock.BoardType = LlbHwGetBoardType();
    
    /* Get peripheral clock rate */
    ArmBlock.ClockRate = LlbHwGetPClk();
    
    /* Get timer and serial port base addresses */
    ArmBlock.TimerRegisterBase = LlbHwGetTmr0Base();
    ArmBlock.UartRegisterBase = LlbHwGetUartBase(LlbHwGetSerialUart());
    
    /* Debug */
    DbgPrint("Machine Identifier: %lx\nPCLK: %d\nTIMER 0: %p\nSERIAL UART: %p\n",
             ArmBlock.BoardType,
             ArmBlock.ClockRate,
             ArmBlock.TimerRegisterBase,
             ArmBlock.UartRegisterBase);
    
    /* Now load the memory map */
    ArmBlock.MemoryMap = MemoryMap;
    
    /* Write firmware callbacks */
    ArmBlock.ConsPutChar = LlbFwPutChar;
    ArmBlock.ConsKbHit = LlbFwKbHit;
    ArmBlock.ConsGetCh = LlbFwGetCh;
    ArmBlock.VideoClearScreen = LlbFwVideoClearScreen;
    ArmBlock.VideoSetDisplayMode = LlbFwVideoSetDisplayMode;
    ArmBlock.VideoGetDisplaySize = LlbFwVideoGetDisplaySize;
    ArmBlock.VideoPutChar = LlbFwVideoPutChar;
    ArmBlock.GetTime = LlbFwGetTime;
}