s3c2440的簡單BOOTLOADER
mian.c
#define BUF_SIZE 100
#define GPHCON (*(volatile unsigned long *)0x56000070)
#define GPHUP (*(volatile unsigned long *)0x56000078)
#define ULCON0 (*(volatile unsigned long *)0x50000000)
#define UCON0 (*(volatile unsigned long *)0x50000004)
#define UFCON0 (*(volatile unsigned long *)0x50000008)
#define UTRSTAT0 (*(volatile unsigned long *)0x50000010)
#define UTXH0 (*(volatile unsigned long *)0x50000020)
#define URXH0 (*(volatile unsigned long *)0x50000024)
#define UBRDIV0 (*(volatile unsigned long *)0x50000028)
void init_uart();
void newline();
void bzero(char *buf,int size);
void do_cmd(char *s);
void send_char(char ch);
void send_msg(char *s);
void get_msg(char *buf,int size);
void print_shell();
void delay(int i);
void main(void)
{
init_uart();
char msg[BUF_SIZE];
while(1)
{
bzero(msg,BUF_SIZE);
newline();
print_shell();
get_msg(msg,BUF_SIZE - 2);
do_cmd(msg);
// delay(4);
}
}
void init_uart()
{
GPHCON &= ~(0xf0);
GPHCON |= 0xa0;
GPHUP = 0xc;
ULCON0 = 0x03;
UCON0 = 0x05;
UFCON0 = 0;
UBRDIV0 = 27;
}
void newline()
{
send_char(r);
send_char(n);
}
void bzero(char *buf,int size)
{
int i;
for(i = 0;i < size;i++)
buf[i] = 0;
}
void send_char(char ch)
{
while(!((UTRSTAT0 >> 1) & 1));
UTXH0 = ch;
}
void send_msg(char *s)
{
while(*s !=