testapp.c
2.16 KB
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
#include <PR/rcp.h>
#include <PR/rdb.h>
#define DEV_CNSLE_TX_INTR 0x01 /* intr enable / state bits */
#define DEV_CNSLE_RX_INTR 0x02
// Type changed from long long to int
//typedef unsigned long long DevRegister;
typedef unsigned int DevRegister;
typedef struct DevConsoleRegisters {
DevRegister intr_status; /* r: intr state / w: intr enable */
DevRegister data; /* r: current char / w: send char */
} DevConsoleRegisters;
#define K1BASE (0xA0000000)
#include "skapi.h"
void __putChars(int length, const char *buf);
void __disable_int();
main(int argc, char* argv)
{
volatile DevConsoleRegisters* console = (DevConsoleRegisters*)
(K1BASE+0x01e01000);
//volatile int* secureReg = (int*)(K1BASE+0x04300010);
volatile int* secureReg = (int*)(K1BASE+MI_SEC_MODE_REG);
//static char* s = "hello world\r\n";
//char* s = "hello world\r\n";
char* s = "hi\r\n";
char* p;
int val;
char ch;
char* p1 = "yow";
char* p2 = "sa!";
char* p3 = "\r\n";
for(p = s; *p; p++) {
console->data = *p;
}
val = sk_entry1(4,4);
console->data = (char)val+'0';
console->data = '\r';
console->data = '\n';
val = sk_entry2(3,3);
console->data = (char)val+'0';
console->data = '\r';
console->data = '\n';
val = sk_entry3(4,4);
console->data = (char)val+'0';
console->data = '\r';
console->data = '\n';
for(;;){
if( (console->intr_status)==DEV_CNSLE_RX_INTR ){
ch = (char)console->data;
console->data = ch;
while((console->intr_status)==DEV_CNSLE_RX_INTR );
// don't know why I need to read again
ch = (char)console->data;
}
}
}
/* length can only be 1, 2 or 3 */
void __putChars(int length, const char *buf)
{
int i;
rdbPacket packet;
packet.type=RDB_TYPE_GtoH_PRINT;
packet.length=length;
for(i=0;i<length;i++)
packet.buf[i]=buf[i];
// *( (int *)(PHYS_TO_K1(RDB_BASE_REG)) ) = *((int *)&packet);
*( (unsigned int *)((RDB_BASE_VIRTUAL_ADDR)) ) = *((unsigned int *)&packet);
// *( (int *)(RDB_READ_INTR_REG)) ) = 0;
}