1 | #include "config.h" |
---|
2 | #include "stddefs.h" |
---|
3 | #include "cpuio.h" |
---|
4 | #include "genlib.h" |
---|
5 | #include "cache.h" |
---|
6 | #include "warmstart.h" |
---|
7 | #include "timer.h" |
---|
8 | |
---|
9 | /* devInit(): |
---|
10 | * As a bare minimum, initialize the console UART here using the |
---|
11 | * incoming 'baud' value as the baud rate. |
---|
12 | */ |
---|
13 | void |
---|
14 | devInit(int baud) |
---|
15 | { |
---|
16 | /* ADD_CODE_HERE */ |
---|
17 | } |
---|
18 | |
---|
19 | /* ConsoleBaudSet(): |
---|
20 | * Provide a means to change the baud rate of the running |
---|
21 | * console interface. If the incoming value is not a valid |
---|
22 | * baud rate, then default to 9600. |
---|
23 | * In the early stages of a new port this can be left empty. |
---|
24 | * Return 0 if successful; else -1. |
---|
25 | */ |
---|
26 | int |
---|
27 | ConsoleBaudSet(int baud) |
---|
28 | { |
---|
29 | /* ADD_CODE_HERE */ |
---|
30 | return(0); |
---|
31 | } |
---|
32 | |
---|
33 | /* target_console_empty(): |
---|
34 | * Target-specific portion of flush_console() in chario.c. |
---|
35 | * This function returns 1 if there are no characters waiting to |
---|
36 | * be put out on the UART; else return 0 indicating that the UART |
---|
37 | * is still busy outputting characters from its FIFO. |
---|
38 | * In the early stages of a new port this can simply return 1. |
---|
39 | */ |
---|
40 | int |
---|
41 | target_console_empty(void) |
---|
42 | { |
---|
43 | /* if (UART_OUTPUT_BUFFER_IS_EMPTY()) <- FIX CODE HERE */ |
---|
44 | return(0); |
---|
45 | return(1); |
---|
46 | } |
---|
47 | |
---|
48 | /* target_putchar(): |
---|
49 | * When buffer has space available, load the incoming character |
---|
50 | * into the UART. |
---|
51 | */ |
---|
52 | int |
---|
53 | target_putchar(char c) |
---|
54 | { |
---|
55 | /* Wait for transmit ready bit */ |
---|
56 | while(1) { |
---|
57 | /* if (UART_IS_READY_FOR_CHARACTER()) <- FIX CODE HERE */ |
---|
58 | break; |
---|
59 | } |
---|
60 | |
---|
61 | /* ADD_CODE_HERE |
---|
62 | * Put character into UART buffer here |
---|
63 | */ |
---|
64 | |
---|
65 | return((int)c); |
---|
66 | } |
---|
67 | |
---|
68 | /* target_gotachar(): |
---|
69 | * Return 0 if no char is avaialable at UART rcv fifo; else 1. |
---|
70 | * Do NOT pull character out of fifo, just return status. |
---|
71 | * |
---|
72 | * Define INCLUDE_BLINKLED in config.h and add STATLED_ON() |
---|
73 | * and STATLED_OFF() macros (or functions) so that uMon will |
---|
74 | * run and blink a target LED at a configured (or default 500msec) |
---|
75 | * interval... |
---|
76 | */ |
---|
77 | int |
---|
78 | target_gotachar(void) |
---|
79 | { |
---|
80 | #if INCLUDE_BLINKLED |
---|
81 | static uint8_t ledstate; |
---|
82 | static struct elapsed_tmr tmr; |
---|
83 | |
---|
84 | #ifndef BLINKON_MSEC |
---|
85 | #define BLINKON_MSEC 500 |
---|
86 | #define BLINKOFF_MSEC 500 |
---|
87 | #endif |
---|
88 | |
---|
89 | switch(ledstate) { |
---|
90 | case 0: |
---|
91 | startElapsedTimer(&tmr,BLINKON_MSEC); |
---|
92 | ledstate = 1; |
---|
93 | STATLED_ON(); |
---|
94 | break; |
---|
95 | case 1: |
---|
96 | if(msecElapsed(&tmr)) { |
---|
97 | STATLED_OFF(); |
---|
98 | ledstate = 2; |
---|
99 | startElapsedTimer(&tmr,BLINKOFF_MSEC); |
---|
100 | } |
---|
101 | break; |
---|
102 | case 2: |
---|
103 | if(msecElapsed(&tmr)) { |
---|
104 | STATLED_ON(); |
---|
105 | ledstate = 1; |
---|
106 | startElapsedTimer(&tmr,BLINKON_MSEC); |
---|
107 | } |
---|
108 | break; |
---|
109 | } |
---|
110 | #endif |
---|
111 | /* if (UART_INPUT_BUFFER_IS_NOT_EMPTY()) <- FIX CODE HERE */ |
---|
112 | return(1); |
---|
113 | return(0); |
---|
114 | } |
---|
115 | |
---|
116 | /* target_getchar(): |
---|
117 | * Assume there is a character in the UART's input buffer and just |
---|
118 | * pull it out and return it. |
---|
119 | */ |
---|
120 | int |
---|
121 | target_getchar(void) |
---|
122 | { |
---|
123 | char c; |
---|
124 | |
---|
125 | /* c = GET_CHARACTER_FROM_UART(); <- FIX CODE HERE */ |
---|
126 | return((int)c); |
---|
127 | } |
---|
128 | |
---|
129 | /* intsoff(): |
---|
130 | * Disable all system interrupts here and return a value that can |
---|
131 | * be used by intsrestore() (later) to restore the interrupt state. |
---|
132 | */ |
---|
133 | ulong |
---|
134 | intsoff(void) |
---|
135 | { |
---|
136 | ulong status; |
---|
137 | |
---|
138 | /* ADD_CODE_HERE */ |
---|
139 | return(status); |
---|
140 | } |
---|
141 | |
---|
142 | /* intsrestore(): |
---|
143 | * Re-establish system interrupts here by using the status value |
---|
144 | * that was returned by an earlier call to intsoff(). |
---|
145 | */ |
---|
146 | void |
---|
147 | intsrestore(ulong status) |
---|
148 | { |
---|
149 | /* ADD_CODE_HERE */ |
---|
150 | } |
---|
151 | |
---|
152 | /* cacheInitForTarget(): |
---|
153 | * Establish target specific function pointers and |
---|
154 | * enable i-cache... |
---|
155 | * Refer to $core/cache.c for a description of the function pointers. |
---|
156 | * NOTE: |
---|
157 | * If cache (either I or D or both) is enabled, then it is important |
---|
158 | * that the appropriate cacheflush/invalidate function be established. |
---|
159 | * This is very important because programs (i.e. cpu instructions) are |
---|
160 | * transferred to memory using data memory accesses and could |
---|
161 | * potentially result in cache coherency problems. |
---|
162 | */ |
---|
163 | void |
---|
164 | cacheInitForTarget(void) |
---|
165 | { |
---|
166 | /* ADD_CODE_HERE */ |
---|
167 | } |
---|
168 | |
---|
169 | /* target_reset(): |
---|
170 | * The default (absolute minimum) action to be taken by this function |
---|
171 | * is to call monrestart(INITIALIZE). It would be better if there was |
---|
172 | * some target-specific function that would really cause the target |
---|
173 | * to reset... |
---|
174 | */ |
---|
175 | void |
---|
176 | target_reset(void) |
---|
177 | { |
---|
178 | flushDcache(0,0); |
---|
179 | disableDcache(); |
---|
180 | invalidateIcache(0,0); |
---|
181 | disableIcache(); |
---|
182 | monrestart(INITIALIZE); |
---|
183 | } |
---|
184 | |
---|
185 | /* If any CPU IO wasn't initialized in reset.S, do it here... |
---|
186 | * This just provides a "C-level" IO init opportunity. |
---|
187 | */ |
---|
188 | void |
---|
189 | initCPUio(void) |
---|
190 | { |
---|
191 | /* ADD_CODE_HERE */ |
---|
192 | } |
---|