blob: 02903cf214cce2ee7c5c019d36029150c13ec71a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/* A small test program to demonstrate use of UARTs and clock */
#define RXADATA (int *) 0x01F800E0
#define RXBDATA (int *) 0x01F800E4
#define RXSTAT (int *) 0x01F800E8
int write (fd, buf, nbyte)
int fd;
char *buf;
int nbyte;
{
int *rxadata;
int rxmask;
int nsave;
volatile *rxstat;
nsave = nbyte;
switch (fd) {
case 0 :
rxadata = RXADATA;
rxmask = 6;
break;
case 1 :
rxadata = RXBDATA;
rxmask = 0x60000;
break;
default:
return (-1);
}
rxstat = RXSTAT;
while (nbyte > 0) {
while ((*rxstat & rxmask) == 0);
*rxadata = *buf;
buf++;
nbyte--;
}
return (nsave);
}
int read (fd, buf, nbyte)
int fd;
char *buf;
int nbyte;
{
int rxmask,*rxadata;
int nsave;
volatile *rxstat;
nsave = nbyte;
switch (fd) {
case 0 :
rxadata = RXADATA;
rxmask = 1;
break;
case 1 :
rxadata = RXBDATA;
rxmask = 0x10000;
break;
default:
return (-1);
}
rxstat = RXSTAT;
while (nbyte > 0) {
while ((*rxstat & rxmask) == 0);
*buf = *rxadata;
buf++;
nbyte--;
}
return (nsave);
}
char *
puts(s)
char *s;
{
while (*s) write(0,s++,1);
}
main()
{
puts("Hello world!\n");
}
|