Changeset 36 in XOpenSparcT1 for trunk/sw/uart.c


Ignore:
Timestamp:
04/11/11 09:54:25 (13 years ago)
Author:
pntsvt00
Message:

modificati i file per la compilazione. boot.s linkato a 0xFFF0000020

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sw/uart.c

    r34 r36  
    11#include "uart.h" 
    22 
    3 const long UART_BASE_ADR[1] = {0x800000FFF0C2C000}; 
    4 const int UART_BAUDS[1] = {0}; 
     3#define BASE_UART 0x800000FFF0C2C000  
     4#define BAUD_UART 100000  
     5//const long UART_BASE_ADR[1] = {0x800000FFF0C2C000}; 
     6//const int UART_BAUDS[1] = {0}; 
    57const int BAUD_RATE =100000; 
    68const int IN_CLK =50000000; 
     
    1214#define WAIT_FOR_XMITR(core)                    \ 
    1315do { \ 
    14 lsr = REG8(UART_BASE_ADR[core] + UART_LSR); \ 
     16lsr = REG8(BASE_UART + UART_LSR); \ 
    1517} while ((lsr & BOTH_EMPTY) != BOTH_EMPTY) 
    1618 
    1719#define WAIT_FOR_THRE(core)                     \ 
    1820do { \ 
    19 lsr = REG8(UART_BASE_ADR[core] + UART_LSR); \ 
     21lsr = REG8(BASE_UART + UART_LSR); \ 
    2022} while ((lsr & UART_LSR_THRE) != UART_LSR_THRE) 
    2123 
    22 #define CHECK_FOR_CHAR(core) (REG8(UART_BASE_ADR[core] + UART_LSR) & UART_LSR_DR) 
     24#define CHECK_FOR_CHAR(core) (REG8(BASE_UART + UART_LSR) & UART_LSR_DR) 
    2325 
    2426#define WAIT_FOR_CHAR(core)                     \ 
    2527do { \ 
    26 lsr = REG8(UART_BASE_ADR[core] + UART_LSR); \ 
     28lsr = REG8(BASE_UART + UART_LSR); \ 
    2729} while ((lsr & UART_LSR_DR) != UART_LSR_DR) 
    2830 
     
    5052*/ 
    5153        uart_init(0); 
     54 
    5255        for(;;) {  
    5356                uart_puts(0,"XOpenSparc is alive \n");  
     
    6265        //float float_divisor; 
    6366        /* Reset receiver and transmiter */ 
    64         REG8( UART_FCR ) = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_14; 
    65         //asm("clr %sp \n");     
     67        asm("nop \n");   
     68        asm("nop \n");   
     69        asm("nop \n");   
     70        asm("nop \n"); 
     71        REG8( BASE_UART + UART_FCR ) = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_14; 
     72        //REG8( UART_BASE_ADR[core] + UART_FCR ) = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_14; 
     73        asm("nop \n");   
     74        asm("nop \n");   
     75        asm("nop \n");   
     76        asm("nop \n");   
     77        asm("nop \n");   
    6678        //asm("sethi %hi(8), %sp \n");   
    6779        //asm("mov 0xfff, %sp \n");      
    6880 
    6981        /* Disable all interrupts */ 
    70         REG8(UART_BASE_ADR[core] + UART_IER) = 0x00; 
     82        REG8(BASE_UART + UART_IER) = 0x00; 
     83        //REG8(UART_BASE_ADR[core] + UART_IER) = 0x00; 
    7184         
    7285        /* Set 8 bit char, 1 stop bit, no parity */ 
    73         REG8(UART_BASE_ADR[core] + UART_LCR) = UART_LCR_WLEN8 & ~(UART_LCR_STOP | UART_LCR_PARITY); 
     86        REG8(BASE_UART + UART_LCR) = UART_LCR_WLEN8 & ~(UART_LCR_STOP | UART_LCR_PARITY); 
    7487         
    7588        /* Set baud rate */ 
     
    7992        divisor = BAUD_RATE; 
    8093 
    81         REG8(UART_BASE_ADR[core] + UART_LCR) |= UART_LCR_DLAB; 
    82         REG8(UART_BASE_ADR[core] + UART_DLL) = divisor & 0x000000ff; 
    83         REG8(UART_BASE_ADR[core] + UART_DLM) = (divisor >> 8) & 0x000000ff; 
    84         REG8(UART_BASE_ADR[core] + UART_LCR) &= ~(UART_LCR_DLAB); 
     94        REG8(BASE_UART + UART_LCR) |= UART_LCR_DLAB; 
     95        REG8(BASE_UART + UART_DLL) = divisor & 0x000000ff; 
     96        REG8(BASE_UART + UART_DLM) = (divisor >> 8) & 0x000000ff; 
     97        REG8(BASE_UART + UART_LCR) &= ~(UART_LCR_DLAB); 
    8598         
    8699        return; 
     
    92105         
    93106        WAIT_FOR_THRE(core); 
    94         REG8(UART_BASE_ADR[core] + UART_TX) = c; 
     107        REG8(BASE_UART + UART_TX) = c; 
    95108        if(c == '\n') { 
    96109                WAIT_FOR_THRE(core); 
    97                 REG8(UART_BASE_ADR[core] + UART_TX) = '\r'; 
     110                REG8(BASE_UART + UART_TX) = '\r'; 
    98111        } 
    99112        WAIT_FOR_XMITR(core); 
Note: See TracChangeset for help on using the changeset viewer.