mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2025-04-21 12:27:27 +03:00
Created xbboot.
This commit is contained in:
18
xbboot/target-common/common-types.h
Normal file
18
xbboot/target-common/common-types.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Authors: Xiangfu Liu <xiangfu@qi-hardware.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_TYPES_H__
|
||||
#define __COMMON_TYPES_H__
|
||||
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
|
||||
#endif // __COMMON_TYPES_H__
|
||||
4864
xbboot/target-common/jz4740.h
Normal file
4864
xbboot/target-common/jz4740.h
Normal file
File diff suppressed because it is too large
Load Diff
65
xbboot/target-common/serial.c
Normal file
65
xbboot/target-common/serial.c
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Authors: Wolfgang Spraul <wolfgang@qi-hardware.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version
|
||||
// 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
|
||||
#include "serial.h"
|
||||
#include "jz4740.h"
|
||||
|
||||
u32 UART_BASE;
|
||||
|
||||
void serial_putc(char c)
|
||||
{
|
||||
volatile u8* uart_lsr = (volatile u8*)(UART_BASE + OFF_LSR);
|
||||
volatile u8* uart_tdr = (volatile u8*)(UART_BASE + OFF_TDR);
|
||||
|
||||
if (c == '\n') serial_putc ('\r');
|
||||
|
||||
/* Wait for fifo to shift out some bytes */
|
||||
while ( !((*uart_lsr & (UART_LSR_TDRQ | UART_LSR_TEMT)) == 0x60) );
|
||||
|
||||
*uart_tdr = (u8) c;
|
||||
}
|
||||
|
||||
void serial_puts(const char *s)
|
||||
{
|
||||
while (*s) serial_putc(*s++);
|
||||
}
|
||||
|
||||
void serial_put_hex(unsigned int v)
|
||||
{
|
||||
unsigned char c[12];
|
||||
char i;
|
||||
for(i = 0; i < 8;i++)
|
||||
{
|
||||
c[i] = (v >> ((7 - i) * 4)) & 0xf;
|
||||
if(c[i] < 10)
|
||||
c[i] += 0x30;
|
||||
else
|
||||
c[i] += (0x41 - 10);
|
||||
}
|
||||
c[8] = '\n';
|
||||
c[9] = 0;
|
||||
serial_puts(c);
|
||||
}
|
||||
|
||||
int serial_getc()
|
||||
{
|
||||
volatile u8* uart_rdr = (volatile u8*)(UART_BASE + OFF_RDR);
|
||||
while (!serial_tstc());
|
||||
return *uart_rdr;
|
||||
}
|
||||
|
||||
int serial_tstc()
|
||||
{
|
||||
volatile u8* uart_lsr = (volatile u8*)(UART_BASE + OFF_LSR);
|
||||
if (*uart_lsr & UART_LSR_DR) {
|
||||
/* Data in rfifo */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
18
xbboot/target-common/serial.h
Normal file
18
xbboot/target-common/serial.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Authors: Wolfgang Spraul <wolfgang@qi-hardware.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version
|
||||
// 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
|
||||
#include "common-types.h"
|
||||
|
||||
extern u32 UART_BASE;
|
||||
|
||||
void serial_putc(char c);
|
||||
void serial_puts(const char *s);
|
||||
void serial_put_hex(unsigned int v);
|
||||
int serial_getc();
|
||||
int serial_tstc();
|
||||
Reference in New Issue
Block a user