1 |
/* |
2 |
* $Id: hello.c,v 1.3 2006/05/22 04:53:52 debug Exp $ |
3 |
* |
4 |
* GXemul demo: Hello World |
5 |
* |
6 |
* This file is in the Public Domain. |
7 |
*/ |
8 |
|
9 |
#include "dev_cons.h" |
10 |
|
11 |
|
12 |
#ifdef MIPS |
13 |
/* Note: The ugly cast to a signed int (32-bit) causes the address to be |
14 |
sign-extended correctly on MIPS when compiled in 64-bit mode */ |
15 |
#define PHYSADDR_OFFSET ((signed int)0xa0000000) |
16 |
#else |
17 |
#define PHYSADDR_OFFSET 0 |
18 |
#endif |
19 |
|
20 |
|
21 |
#define PUTCHAR_ADDRESS (PHYSADDR_OFFSET + \ |
22 |
DEV_CONS_ADDRESS + DEV_CONS_PUTGETCHAR) |
23 |
#define HALT_ADDRESS (PHYSADDR_OFFSET + \ |
24 |
DEV_CONS_ADDRESS + DEV_CONS_HALT) |
25 |
|
26 |
|
27 |
void printchar(char ch) |
28 |
{ |
29 |
*((volatile unsigned char *) PUTCHAR_ADDRESS) = ch; |
30 |
} |
31 |
|
32 |
|
33 |
void halt(void) |
34 |
{ |
35 |
*((volatile unsigned char *) HALT_ADDRESS) = 0; |
36 |
} |
37 |
|
38 |
|
39 |
void printstr(char *s) |
40 |
{ |
41 |
while (*s) |
42 |
printchar(*s++); |
43 |
} |
44 |
|
45 |
|
46 |
void f(void) |
47 |
{ |
48 |
printstr("Hello world\n"); |
49 |
halt(); |
50 |
} |
51 |
|