- Update romcc to version 0.27 and add more tests.

git-svn-id: svn://svn.coreboot.org/coreboot/trunk@865 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Eric Biederman 2003-06-10 21:22:07 +00:00
parent dc18ef018d
commit 6aa31cc754
18 changed files with 6759 additions and 1052 deletions

View File

@ -1,5 +1,5 @@
VERSION:=0.23
RELEASE_DATE:=08 May 2003
VERSION:=0.27
RELEASE_DATE:=10 June 2003
PACKAGE:=romcc
@ -35,8 +35,19 @@ TESTS=\
simple_test18.c \
simple_test19.c \
simple_test20.c \
simple_test21.c \
simple_test22.c \
simple_test23.c \
simple_test24.c \
simple_test25.c \
simple_test26.c \
simple_test27.c \
simple_test28.c \
simple_test29.c \
simple_test30.c \
raminit_test.c \
raminit_test2.c
raminit_test2.c \
raminit_test3.c
TEST_SRCS:=$(patsubst %, tests/%, $(TESTS))
TEST_ASM:=$(patsubst %.c, tests/%.S, $(TESTS))
@ -44,13 +55,13 @@ TEST_OBJ:=$(patsubst %.c, tests/%.o, $(TESTS))
TEST_ELF:=$(patsubst %.c, tests/%.elf, $(TESTS))
$(TEST_ASM): %.S: %.c romcc
export ALLOC_CHECK_=2; ./romcc -O $< > $@
export ALLOC_CHECK_=2; ./romcc -O -o $@ $< > $*.debug
$(TEST_OBJ): %.o: %.S
as $< -o $@
$(TEST_ELF): %.elf: %.o
ld -Ttext 0x1000 $< -o $@
$(TEST_ELF): %.elf: %.o tests/ldscript.ld
ld -T tests/ldscript.ld $< -o $@
test: $(TEST_ELF)
@ -61,5 +72,5 @@ echo:
echo "TEST_ELF=$(TEST_ELF)"
clean:
rm -f romcc core $(TEST_ASM) $(TEST_OBJ) $(TEST_ELF)
rm -f romcc core $(TEST_ASM) $(TEST_OBJ) $(TEST_ELF) tests/*.debug tests/*.debug2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
void outb(unsigned char value, unsigned short port)
{
__builtin_outb(value, port);
}
unsigned char inb(unsigned short port)
{
return __builtin_inb(port);
}
/* Base Address */
#ifndef TTYS0_BASE
#define TTYS0_BASE 0x3f8
#endif
#ifndef TTYS0_BAUD
#define TTYS0_BAUD 115200
#endif
#if ((115200%TTYS0_BAUD) != 0)
#error Bad ttys0 baud rate
#endif
#if TTYS0_BAUD == 115200
#define TTYS0_DIV (1)
#else
#define TTYS0_DIV (115200/TTYS0_BAUD)
#endif
/* Line Control Settings */
#ifndef TTYS0_LCS
/* Set 8bit, 1 stop bit, no parity */
#define TTYS0_LCS 0x3
#endif
#define UART_LCS TTYS0_LCS
/* Data */
#define UART_RBR 0x00
#define UART_TBR 0x00
/* Control */
#define UART_IER 0x01
#define UART_IIR 0x02
#define UART_FCR 0x02
#define UART_LCR 0x03
#define UART_MCR 0x04
#define UART_DLL 0x00
#define UART_DLM 0x01
/* Status */
#define UART_LSR 0x05
#define UART_MSR 0x06
#define UART_SCR 0x07
int uart_can_tx_byte(void)
{
return inb(TTYS0_BASE + UART_LSR) & 0x20;
}
void uart_wait_to_tx_byte(void)
{
while(!uart_can_tx_byte())
;
}
void uart_wait_until_sent(void)
{
while(!(inb(TTYS0_BASE + UART_LSR) & 0x40))
;
}
static void uart_tx_byte(unsigned char data)
{
uart_wait_to_tx_byte();
outb(data, TTYS0_BASE + UART_TBR);
/* Make certain the data clears the fifos */
uart_wait_until_sent();
}
void uart_init(void)
{
/* disable interrupts */
outb(0x0, TTYS0_BASE + UART_IER);
/* enable fifo's */
outb(0x01, TTYS0_BASE + UART_FCR);
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
outb(0x80 | UART_LCS, TTYS0_BASE + UART_LCR);
outb(TTYS0_DIV & 0xFF, TTYS0_BASE + UART_DLL);
outb((TTYS0_DIV >> 8) & 0xFF, TTYS0_BASE + UART_DLM);
outb(UART_LCS, TTYS0_BASE + UART_LCR);
}
void __console_tx_char(unsigned char byte)
{
uart_tx_byte(byte);
}
void __console_tx_string(char *str)
{
unsigned char ch;
while((ch = *str++) != '\0') {
__console_tx_char(ch);
}
}
void print_debug_char(unsigned char byte) { __console_tx_char(byte); }
void print_debug(char *str) { __console_tx_string(str); }
void main(void)
{
static const char msg[] = "hello world\r\n";
uart_init();
#if 0
print_debug(msg);
#endif
#if 1
print_debug("hello world\r\n");
#endif
while(1) {
;
}
}

View File

@ -0,0 +1,20 @@
ENTRY(_start)
SECTIONS
{
. = 0x1000;
.text . : {
. = ALIGN(16);
_start = . ;
*(.rom.text);
*(.text)
. = ALIGN(16);
}
.data . : {
. = ALIGN(16);
*(.rom.data);
*(.data)
. = ALIGN(16);
}
}

View File

@ -1,7 +1,8 @@
#define HAVE_STRING_SUPPORT 0
#define HAVE_CAST_SUPPORT 0
#define HAVE_STATIC_ARRAY_SUPPORT 0
#define HAVE_POINTER_SUPPORT 0
#define HAVE_CAST_SUPPORT 1
#define HAVE_STATIC_ARRAY_SUPPORT 1
#define HAVE_POINTER_SUPPORT 1
#define HAVE_MACRO_ARG_SUPPORT 0
void outb(unsigned char value, unsigned short port)
{
@ -196,7 +197,7 @@ void __console_tx_string(char *str)
{
unsigned char ch;
while((ch = *str++) != '\0') {
__console_tx_byte(ch);
__console_tx_char(ch);
}
}
#else
@ -1112,7 +1113,11 @@ static void dimms_read(unsigned long offset)
print_debug("\n");
#endif
#if HAVE_POINTER_SUPPORT
#if HAVE_MACRO_ARG_SUPPORT
dummy = RAM(unsigned long, addr);
#else
dummy = *((volatile unsigned long *)(addr));
#endif
#endif
#if HAVE_STRING_SUPPORT
print_debug("Reading ");
@ -1120,7 +1125,11 @@ static void dimms_read(unsigned long offset)
print_debug("\n");
#endif
#if HAVE_POINTER_SUPPORT
#if HAVE_MACRO_ARG_SUPPORT
dummy = RAM(unsigned long, addr ^ 0xdff8);
#else
dummy = *((volatile unsigned long *)(addr ^ 0xdff8));
#endif
#endif
#if HAVE_STRING_SUPPORT
print_debug("Read ");

View File

@ -1,7 +1,8 @@
#define HAVE_STRING_SUPPORT 0
#define HAVE_CAST_SUPPORT 0
#define HAVE_STATIC_ARRAY_SUPPORT 0
#define HAVE_POINTER_SUPPORT 0
#define HAVE_STRING_SUPPORT 1
#define HAVE_CAST_SUPPORT 1
#define HAVE_STATIC_ARRAY_SUPPORT 1
#define HAVE_POINTER_SUPPORT 1
#define HAVE_MACRO_ARG_SUPPORT 0
void outb(unsigned char value, unsigned short port)
{
@ -196,7 +197,7 @@ void __console_tx_string(char *str)
{
unsigned char ch;
while((ch = *str++) != '\0') {
__console_tx_byte(ch);
__console_tx_char(ch);
}
}
#else
@ -1112,7 +1113,11 @@ static void dimms_read(unsigned long offset)
print_debug("\n");
#endif
#if HAVE_POINTER_SUPPORT
#if HAVE_MACRO_ARG_SUPPORT
dummy = RAM(unsigned long, addr);
#else
dummy = *((volatile unsigned long *)(addr));
#endif
#endif
#if HAVE_STRING_SUPPORT
print_debug("Reading ");
@ -1120,7 +1125,11 @@ static void dimms_read(unsigned long offset)
print_debug("\n");
#endif
#if HAVE_POINTER_SUPPORT
#if HAVE_MACRO_ARG_SUPPORT
dummy = RAM(unsigned long, addr ^ 0xdff8);
#else
dummy = *((volatile unsigned long *)(addr ^ 0xdff8));
#endif
#endif
#if HAVE_STRING_SUPPORT
print_debug("Read ");

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
static void main(void)
{
asm("hlt");
}

View File

@ -0,0 +1,306 @@
struct syscall_result {
long val;
int errno;
};
static struct syscall_result syscall_return(long result)
{
struct syscall_result res;
if (((unsigned long)result) >= ((unsigned long)-125)) {
res.errno = - result;
res.val = -1;
} else {
res.errno = 0;
res.val = result;
}
return res;
}
static struct syscall_result syscall0(unsigned long nr)
{
long res;
asm volatile(
"int $0x80"
: "a" (res)
: "a" (nr));
return syscall_return(res);
}
static struct syscall_result syscall1(unsigned long nr, unsigned long arg1)
{
long res;
asm volatile(
"int $0x80"
: "a" (res)
: "a" (nr), "b" (arg1));
return syscall_return(res);
}
static struct syscall_result syscall2(unsigned long nr, unsigned long arg1, unsigned long arg2)
{
long res;
asm volatile(
"int $0x80"
: "a" (res)
: "a" (nr), "b" (arg1), "c" (arg2));
return syscall_return(res);
}
static struct syscall_result syscall3(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3)
{
long res;
asm volatile(
"int $0x80"
: "a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3));
return syscall_return(res);
}
static struct syscall_result syscall4(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4)
{
long res;
asm volatile(
"int $0x80"
: "a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4));
return syscall_return(res);
}
static struct syscall_result syscall5(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5)
{
long res;
asm volatile(
"int $0x80"
: "a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3),
"S" (arg4), "D" (arg5));
return syscall_return(res);
}
#define NR_exit 1
#define NR_fork 2
#define NR_read 3
#define NR_write 4
#define NR_open 5
#define NR_close 6
#define NR_waitpid 7
#define NR_creat 8
#define NR_link 9
#define NR_unlink 10
#define NR_execve 11
#define NR_chdir 12
#define NR_time 13
#define NR_mknod 14
#define NR_chmod 15
#define NR_lchown 16
#define NR_break 17
#define NR_oldstat 18
#define NR_lseek 19
#define NR_getpid 20
#define NR_mount 21
#define NR_umount 22
#define NR_setuid 23
#define NR_getuid 24
#define NR_stime 25
#define NR_ptrace 26
#define NR_alarm 27
#define NR_oldfstat 28
#define NR_pause 29
#define NR_utime 30
#define NR_stty 31
#define NR_gtty 32
#define NR_access 33
#define NR_nice 34
#define NR_ftime 35
#define NR_sync 36
#define NR_kill 37
#define NR_rename 38
#define NR_mkdir 39
#define NR_rmdir 40
#define NR_dup 41
#define NR_pipe 42
#define NR_times 43
#define NR_prof 44
#define NR_brk 45
#define NR_setgid 46
#define NR_getgid 47
#define NR_signal 48
#define NR_geteuid 49
#define NR_getegid 50
#define NR_acct 51
#define NR_umount2 52
#define NR_lock 53
#define NR_ioctl 54
#define NR_fcntl 55
#define NR_mpx 56
#define NR_setpgid 57
#define NR_ulimit 58
#define NR_oldolduname 59
#define NR_umask 60
#define NR_chroot 61
#define NR_ustat 62
#define NR_dup2 63
#define NR_getppid 64
#define NR_getpgrp 65
#define NR_setsid 66
#define NR_sigaction 67
#define NR_sgetmask 68
#define NR_ssetmask 69
#define NR_setreuid 70
#define NR_setregid 71
#define NR_sigsuspend 72
#define NR_sigpending 73
#define NR_sethostname 74
#define NR_setrlimit 75
#define NR_getrlimit 76
#define NR_getrusage 77
#define NR_gettimeofday 78
#define NR_settimeofday 79
#define NR_getgroups 80
#define NR_setgroups 81
#define NR_select 82
#define NR_symlink 83
#define NR_oldlstat 84
#define NR_readlink 85
#define NR_uselib 86
#define NR_swapon 87
#define NR_reboot 88
#define NR_readdir 89
#define NR_mmap 90
#define NR_munmap 91
#define NR_truncate 92
#define NR_ftruncate 93
#define NR_fchmod 94
#define NR_fchown 95
#define NR_getpriority 96
#define NR_setpriority 97
#define NR_profil 98
#define NR_statfs 99
#define NR_fstatfs 100
#define NR_ioperm 101
#define NR_socketcall 102
#define NR_syslog 103
#define NR_setitimer 104
#define NR_getitimer 105
#define NR_stat 106
#define NR_lstat 107
#define NR_fstat 108
#define NR_olduname 109
#define NR_iopl 110
#define NR_vhangup 111
#define NR_idle 112
#define NR_vm86old 113
#define NR_wait4 114
#define NR_swapoff 115
#define NR_sysinfo 116
#define NR_ipc 117
#define NR_fsync 118
#define NR_sigreturn 119
#define NR_clone 120
#define NR_setdomainname 121
#define NR_uname 122
#define NR_modify_ldt 123
#define NR_adjtimex 124
#define NR_mprotect 125
#define NR_sigprocmask 126
#define NR_create_module 127
#define NR_init_module 128
#define NR_delete_module 129
#define NR_get_kernel_syms 130
#define NR_quotactl 131
#define NR_getpgid 132
#define NR_fchdir 133
#define NR_bdflush 134
#define NR_sysfs 135
#define NR_personality 136
#define NR_afs_syscall 137 /* Syscall for Andrew File System */
#define NR_setfsuid 138
#define NR_setfsgid 139
#define NR__llseek 140
#define NR_getdents 141
#define NR__newselect 142
#define NR_flock 143
#define NR_msync 144
#define NR_readv 145
#define NR_writev 146
#define NR_getsid 147
#define NR_fdatasync 148
#define NR__sysctl 149
#define NR_mlock 150
#define NR_munlock 151
#define NR_mlockall 152
#define NR_munlockall 153
#define NR_sched_setparam 154
#define NR_sched_getparam 155
#define NR_sched_setscheduler 156
#define NR_sched_getscheduler 157
#define NR_sched_yield 158
#define NR_sched_get_priority_max 159
#define NR_sched_get_priority_min 160
#define NR_sched_rr_get_interval 161
#define NR_nanosleep 162
#define NR_mremap 163
#define NR_setresuid 164
#define NR_getresuid 165
#define NR_vm86 166
#define NR_query_module 167
#define NR_poll 168
#define NR_nfsservctl 169
#define NR_setresgid 170
#define NR_getresgid 171
#define NR_prctl 172
#define NR_rt_sigreturn 173
#define NR_rt_sigaction 174
#define NR_rt_sigprocmask 175
#define NR_rt_sigpending 176
#define NR_rt_sigtimedwait 177
#define NR_rt_sigqueueinfo 178
#define NR_rt_sigsuspend 179
#define NR_pread 180
#define NR_pwrite 181
#define NR_chown 182
#define NR_getcwd 183
#define NR_capget 184
#define NR_capset 185
#define NR_sigaltstack 186
#define NR_sendfile 187
#define NR_getpmsg 188 /* some people actually want streams */
#define NR_putpmsg 189 /* some people actually want streams */
#define NR_vfork 190
typedef long ssize_t;
typedef unsigned long size_t;
/* Standard file descriptors */
#define STDIN_FILENO 0 /* Standard input */
#define STDOUT_FILENO 1 /* Standard output */
#define STDERR_FILENO 2 /* Standard error output */
static ssize_t write(int fd, const void *buf, size_t count)
{
struct syscall_result res;
res = syscall3(NR_write, fd, (unsigned long)buf, count);
return res.val;
}
static void _exit(int status)
{
struct syscall_result res;
res = syscall1(NR_exit, status);
}
static void main(void)
{
static const char msg[] = "hello world\r\n";
write(STDOUT_FILENO, msg, sizeof(msg));
_exit(0);
}

View File

@ -0,0 +1,18 @@
static void print(char *str)
{
while(1) {
unsigned char ch;
ch = *str;
if (ch == '\0') {
break;
}
__builtin_outb(ch, 0x1234);
str += 1;
}
}
static void main(void)
{
print("hello world\r\n");
print("how are you today\r\n");
}

View File

@ -0,0 +1,16 @@
void smbus_read_byte(void)
{
unsigned char host_status_register;
unsigned char byte;
int result;
host_status_register = __builtin_inb(0x1234);
/* read results of transaction */
byte = __builtin_inb(0x4567);
result = byte;
if (host_status_register != 0x02) {
result = -1;
}
}

View File

@ -0,0 +1,109 @@
#define COUNT 26
static void main(void)
{
unsigned char a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
a = 1;
b = 2;
c = 3;
d = 4;
e = 5;
f = 6;
g = 7;
h = 8;
i = 9;
j = 10;
k = 11;
l = 12;
m = 13;
n = 14;
o = 15;
p = 16;
q = 17;
r = 18;
s = 19;
t = 20;
u = 21;
v = 22;
w = 23;
x = 24;
y = 25;
z = 26;
#if COUNT >= 26
__builtin_outb(z, 0xab);
#endif
#if COUNT >= 25
__builtin_outb(y, 0xab);
#endif
#if COUNT >= 24
__builtin_outb(x, 0xab);
#endif
#if COUNT >= 23
__builtin_outb(w, 0xab);
#endif
#if COUNT >= 22
__builtin_outb(v, 0xab);
#endif
#if COUNT >= 21
__builtin_outb(u, 0xab);
#endif
#if COUNT >= 20
__builtin_outb(t, 0xab);
#endif
#if COUNT >= 19
__builtin_outb(s, 0xab);
#endif
#if COUNT >= 18
__builtin_outb(r, 0xab);
#endif
#if COUNT >= 17
__builtin_outb(q, 0xab);
#endif
#if COUNT >= 16
__builtin_outb(p, 0xab);
#endif
#if COUNT >= 15
__builtin_outb(o, 0xab);
#endif
#if COUNT >= 14
__builtin_outb(n, 0xab);
#endif
#if COUNT >= 13
__builtin_outb(m, 0xab);
#endif
#if COUNT >= 12
__builtin_outb(l, 0xab);
#endif
#if COUNT >= 11
__builtin_outb(k, 0xab);
#endif
#if COUNT >= 10
__builtin_outb(j, 0xab);
#endif
#if COUNT >= 9
__builtin_outb(i, 0xab);
#endif
#if COUNT >= 8
__builtin_outb(h, 0xab);
#endif
#if COUNT >= 7
__builtin_outb(g, 0xab);
#endif
#if COUNT >= 6
__builtin_outb(f, 0xab);
#endif
#if COUNT >= 5
__builtin_outb(e, 0xab);
#endif
#if COUNT >= 4
__builtin_outb(d, 0xab);
#endif
#if COUNT >= 3
__builtin_outb(c, 0xab);
#endif
#if COUNT >= 2
__builtin_outb(b, 0xab);
#endif
#if COUNT >= 1
__builtin_outb(a, 0xab);
#endif
}

View File

@ -0,0 +1,109 @@
#define COUNT 23
static void main(void)
{
unsigned int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
a = __builtin_inb(0xab);
b = __builtin_inb(0xab);
c = __builtin_inb(0xab);
d = __builtin_inb(0xab);
e = __builtin_inb(0xab);
f = __builtin_inb(0xab);
g = __builtin_inb(0xab);
h = __builtin_inb(0xab);
i = __builtin_inb(0xab);
j = __builtin_inb(0xab);
k = __builtin_inb(0xab);
l = __builtin_inb(0xab);
m = __builtin_inb(0xab);
n = __builtin_inb(0xab);
o = __builtin_inb(0xab);
p = __builtin_inb(0xab);
q = __builtin_inb(0xab);
r = __builtin_inb(0xab);
s = __builtin_inb(0xab);
t = __builtin_inb(0xab);
u = __builtin_inb(0xab);
v = __builtin_inb(0xab);
w = __builtin_inb(0xab);
x = __builtin_inb(0xab);
y = __builtin_inb(0xab);
z = __builtin_inb(0xab);
#if COUNT >= 26
__builtin_outb(z, 0xab);
#endif
#if COUNT >= 25
__builtin_outb(y, 0xab);
#endif
#if COUNT >= 24
__builtin_outb(x, 0xab);
#endif
#if COUNT >= 23
__builtin_outb(w, 0xab);
#endif
#if COUNT >= 22
__builtin_outb(v, 0xab);
#endif
#if COUNT >= 21
__builtin_outb(u, 0xab);
#endif
#if COUNT >= 20
__builtin_outb(t, 0xab);
#endif
#if COUNT >= 19
__builtin_outb(s, 0xab);
#endif
#if COUNT >= 18
__builtin_outb(r, 0xab);
#endif
#if COUNT >= 17
__builtin_outb(q, 0xab);
#endif
#if COUNT >= 16
__builtin_outb(p, 0xab);
#endif
#if COUNT >= 15
__builtin_outb(o, 0xab);
#endif
#if COUNT >= 14
__builtin_outb(n, 0xab);
#endif
#if COUNT >= 13
__builtin_outb(m, 0xab);
#endif
#if COUNT >= 12
__builtin_outb(l, 0xab);
#endif
#if COUNT >= 11
__builtin_outb(k, 0xab);
#endif
#if COUNT >= 10
__builtin_outb(j, 0xab);
#endif
#if COUNT >= 9
__builtin_outb(i, 0xab);
#endif
#if COUNT >= 8
__builtin_outb(h, 0xab);
#endif
#if COUNT >= 7
__builtin_outb(g, 0xab);
#endif
#if COUNT >= 6
__builtin_outb(f, 0xab);
#endif
#if COUNT >= 5
__builtin_outb(e, 0xab);
#endif
#if COUNT >= 4
__builtin_outb(d, 0xab);
#endif
#if COUNT >= 3
__builtin_outb(c, 0xab);
#endif
#if COUNT >= 2
__builtin_outb(b, 0xab);
#endif
#if COUNT >= 1
__builtin_outb(a, 0xab);
#endif
}

View File

@ -0,0 +1,133 @@
void outb(unsigned char value, unsigned short port)
{
__builtin_outb(value, port);
}
unsigned char inb(unsigned short port)
{
return __builtin_inb(port);
}
/* Base Address */
#ifndef TTYS0_BASE
#define TTYS0_BASE 0x3f8
#endif
#ifndef TTYS0_BAUD
#define TTYS0_BAUD 115200
#endif
#if ((115200%TTYS0_BAUD) != 0)
#error Bad ttys0 baud rate
#endif
#if TTYS0_BAUD == 115200
#define TTYS0_DIV (1)
#else
#define TTYS0_DIV (115200/TTYS0_BAUD)
#endif
/* Line Control Settings */
#ifndef TTYS0_LCS
/* Set 8bit, 1 stop bit, no parity */
#define TTYS0_LCS 0x3
#endif
#define UART_LCS TTYS0_LCS
/* Data */
#define UART_RBR 0x00
#define UART_TBR 0x00
/* Control */
#define UART_IER 0x01
#define UART_IIR 0x02
#define UART_FCR 0x02
#define UART_LCR 0x03
#define UART_MCR 0x04
#define UART_DLL 0x00
#define UART_DLM 0x01
/* Status */
#define UART_LSR 0x05
#define UART_MSR 0x06
#define UART_SCR 0x07
int uart_can_tx_byte(void)
{
return inb(TTYS0_BASE + UART_LSR) & 0x20;
}
void uart_wait_to_tx_byte(void)
{
while(!uart_can_tx_byte())
;
}
void uart_wait_until_sent(void)
{
while(!(inb(TTYS0_BASE + UART_LSR) & 0x40))
;
}
static void uart_tx_byte(unsigned char data)
{
uart_wait_to_tx_byte();
outb(data, TTYS0_BASE + UART_TBR);
/* Make certain the data clears the fifos */
uart_wait_until_sent();
}
void uart_init(void)
{
/* disable interrupts */
outb(0x0, TTYS0_BASE + UART_IER);
/* enable fifo's */
outb(0x01, TTYS0_BASE + UART_FCR);
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
outb(0x80 | UART_LCS, TTYS0_BASE + UART_LCR);
outb(TTYS0_DIV & 0xFF, TTYS0_BASE + UART_DLL);
outb((TTYS0_DIV >> 8) & 0xFF, TTYS0_BASE + UART_DLM);
outb(UART_LCS, TTYS0_BASE + UART_LCR);
}
void __console_tx_char(unsigned char byte)
{
uart_tx_byte(byte);
}
void __console_tx_string(char *str)
{
unsigned char ch;
while((ch = *str++) != '\0') {
__console_tx_char(ch);
}
}
void print_debug_char(unsigned char byte) { __console_tx_char(byte); }
void print_debug(char *str) { __console_tx_string(str); }
void main(void)
{
static const char msg[] = "hello world\r\n";
uart_init();
#if 0
print_debug(msg);
#endif
#if 1
print_debug("hello world\r\n");
print_debug("how are you today\r\n");
#endif
while(1) {
;
}
}
void main2(void)
{
main();
}

View File

@ -0,0 +1,24 @@
static void outl(unsigned int value, unsigned short port)
{
__builtin_outl(value, port);
}
static unsigned char inl(unsigned short port)
{
return __builtin_inl(port);
}
static void setup_coherent_ht_domain(void)
{
static const unsigned int register_values[] = {
( (((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) | (((0) & 0x07) << 8) | ((0x40) & 0xFF)), 0xfff0f0f0, 0x00010101,
};
unsigned long reg;
reg = inl(0xFC);
reg &= register_values[1];
reg |= register_values[2] & ~register_values[1];
outl(register_values[0], 0xF8);
outl(reg, 0xFC);
}

View File

@ -0,0 +1,37 @@
static void outb(unsigned char value, unsigned short port)
{
__builtin_outb(value, port);
}
static unsigned char inb(unsigned short port)
{
return __builtin_inb(port);
}
static void __console_tx_byte(unsigned char byte)
{
while(inb(0x3f8 + 0x05))
;
outb(byte, 0x3f8 + 0x00);
}
static void __console_tx_string(int loglevel, const char *str)
{
if (8 > loglevel) {
unsigned char ch;
while((ch = *str++) != '\0') {
__console_tx_byte(ch);
}
}
}
static void console_init(void)
{
static const char console_test[] =
"\r\n\r\nLinuxBIOS-"
"1.1.0"
".0Fallback"
" "
"Mon Jun 9 18:15:20 MDT 2003"
" starting...\r\n";
__console_tx_string(6, console_test);
}

File diff suppressed because it is too large Load Diff

View File

@ -260,7 +260,7 @@ static void test(void)
#if 1
outb(m, 0xab);
#endif
#if 0
#if 1
outb(n, 0xab);
#endif
#if 0