source: umon/ports/template/cpuio.c @ 87db514

Last change on this file since 87db514 was 87db514, checked in by Amar Takhar <amar@…>, on 04/16/15 at 19:26:21

Initial commit of the umon repository.

Prior to this three changes were made:

  • Remove umon_ prefix from parent directories.
  • Collapse main/target/ into main/
  • Remove ports/template/flashtest.scr.ucon script.
  • Property mode set to 100644
File size: 4.2 KB
Line 
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 */
13void
14devInit(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 */
26int
27ConsoleBaudSet(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 */
40int
41target_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 */
52int
53target_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 */
77int
78target_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 */
120int
121target_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 */
133ulong
134intsoff(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 */
146void
147intsrestore(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 */
163void
164cacheInitForTarget(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 */
175void
176target_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 */
188void
189initCPUio(void)
190{
191        /* ADD_CODE_HERE */
192}
Note: See TracBrowser for help on using the repository browser.