]>
Commit | Line | Data |
---|---|---|
1 | #include "stdafx.h" | |
2 | #include "tester1.h" | |
3 | #include <commctrl.h> | |
4 | //#include <aygshell.h> | |
5 | #include <sipapi.h> | |
6 | #include "setup.h" | |
7 | ||
8 | // moved to config.h | |
9 | //#define FUART 0x40100000 | |
10 | ||
11 | ||
12 | void UART_puts(char *s) | |
13 | { | |
14 | UINT32 *base=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE); | |
15 | int ret=VirtualCopy(base,(void *) ((UARTBASE)/256),sizeof(void*)*0xffff , PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); | |
16 | int a=0; | |
17 | while(s[a]) | |
18 | { | |
19 | while((base[UARTSTATUS/4]&1<<UARTTXRDY) == UARTTXBIT) {} | |
20 | base[UARTDATA/4]=(char)(s[a]); | |
21 | a++; | |
22 | } | |
23 | } | |
24 | ||
25 | void UART_setup() | |
26 | { | |
27 | UINT32 *base=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE); | |
28 | int ret=VirtualCopy(base,(void *) ((UARTBASE)/256),sizeof(void*)*0xffff , PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); | |
29 | ||
30 | #ifdef STRONGARM | |
31 | // Apparently there is something we don't know. This is needed. | |
32 | HANDLE hSerial = CreateFile(L"COM1:", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); | |
33 | // disable UART | |
34 | base[0x0C/4] = 0; | |
35 | // clear status | |
36 | base[0x1C/4] = 0xFF; | |
37 | // set 8 bit no parity 1 stopbit | |
38 | base[0x00/4] = 9; | |
39 | // set 115200 bps | |
40 | base[0x04/4] = 0; | |
41 | base[0x08/4] = 1; | |
42 | // enable TX/RX | |
43 | base[0x0C/4] = 3; | |
44 | #else | |
45 | // set DLAB | |
46 | base[0x0C/4]=128+2+1; | |
47 | // set divisor | |
48 | base[0]=8; // 115200 bps | |
49 | base[0x04/4]=0; | |
50 | // unset DLAB | |
51 | base[0x0C/4]=2+1; | |
52 | // UART enable & no FIFO | |
53 | base[0x04/4]=64; | |
54 | base[0x08/4]=0; | |
55 | #endif | |
56 | ||
57 | char test[]="LinExec: UART Initialized.\n\r"; | |
58 | int a=0; | |
59 | while(test[a]) | |
60 | { | |
61 | while((base[UARTSTATUS/4]&1<<UARTTXRDY) == UARTTXBIT) {} | |
62 | base[UARTDATA/4]=(char)(test[a]); | |
63 | a++; | |
64 | } | |
65 | } |