Rev 2286 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2286 | Rev 2290 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2007 Michal Kebrt, Petr Stepan |
2 | * Copyright (c) 2007 Michal Kebrt, Petr Stepan |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup arm32 |
29 | /** @addtogroup arm32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <interrupt.h> |
35 | #include <interrupt.h> |
36 | #include <ipc/irq.h> |
36 | #include <ipc/irq.h> |
37 | #include <console/chardev.h> |
37 | #include <console/chardev.h> |
38 | #include <arch/drivers/gxemul.h> |
38 | #include <arch/drivers/gxemul.h> |
39 | #include <console/console.h> |
39 | #include <console/console.h> |
40 | #include <sysinfo/sysinfo.h> |
40 | #include <sysinfo/sysinfo.h> |
41 | #include <print.h> |
41 | #include <print.h> |
42 | #include <ddi/device.h> |
42 | #include <ddi/device.h> |
43 | #include <mm/page.h> |
43 | #include <mm/page.h> |
44 | #include <arch/machine.h> |
44 | #include <arch/machine.h> |
45 | 45 | ||
46 | /** Address of devices. */ |
46 | /** Address of devices. */ |
47 | #define GXEMUL_VIDEORAM 0x10000000 |
47 | #define GXEMUL_VIDEORAM 0x10000000 |
48 | #define GXEMUL_KBD 0x10000000 |
48 | #define GXEMUL_KBD 0x10000000 |
49 | #define GXEMUL_RTC 0x15000000 |
49 | #define GXEMUL_RTC 0x15000000 |
50 | #define GXEMUL_RTC_FREQ_OFFSET 0x100 |
50 | #define GXEMUL_RTC_FREQ_OFFSET 0x100 |
51 | #define GXEMUL_RTC_ACK_OFFSET 0x110 |
51 | #define GXEMUL_RTC_ACK_OFFSET 0x110 |
52 | #define GXEMUL_IRQC 0x16000000 |
52 | #define GXEMUL_IRQC 0x16000000 |
53 | #define GXEMUL_IRQC_MASK_OFFSET 0x4 |
53 | #define GXEMUL_IRQC_MASK_OFFSET 0x4 |
54 | #define GXEMUL_IRQC_UNMASK_OFFSET 0x8 |
54 | #define GXEMUL_IRQC_UNMASK_OFFSET 0x8 |
55 | #define GXEMUL_MP 0x11000000 |
55 | #define GXEMUL_MP 0x11000000 |
56 | #define GXEMUL_MP_MEMSIZE_OFFSET 0x0090 |
56 | #define GXEMUL_MP_MEMSIZE_OFFSET 0x0090 |
57 | 57 | ||
58 | 58 | ||
59 | /** IRQs */ |
59 | /** IRQs */ |
60 | #define GXEMUL_KBD_IRQ 2 |
60 | #define GXEMUL_KBD_IRQ 2 |
61 | #define GXEMUL_TIMER_IRQ 4 |
61 | #define GXEMUL_TIMER_IRQ 4 |
62 | 62 | ||
63 | static gxemul_hw_map_t gxemul_hw_map; |
63 | static gxemul_hw_map_t gxemul_hw_map; |
64 | static chardev_t console; |
64 | static chardev_t console; |
65 | static irq_t gxemul_irq; |
65 | static irq_t gxemul_irq; |
66 | static irq_t gxemul_timer_irq; |
66 | static irq_t gxemul_timer_irq; |
67 | 67 | ||
- | 68 | static bool hw_map_init_called = false; |
|
- | 69 | ||
68 | static void gxemul_write(chardev_t *dev, const char ch); |
70 | static void gxemul_write(chardev_t *dev, const char ch); |
69 | static void gxemul_enable(chardev_t *dev); |
71 | static void gxemul_enable(chardev_t *dev); |
70 | static void gxemul_disable(chardev_t *dev); |
72 | static void gxemul_disable(chardev_t *dev); |
71 | static char gxemul_do_read(chardev_t *dev); |
73 | static char gxemul_do_read(chardev_t *dev); |
72 | 74 | ||
73 | static chardev_operations_t gxemul_ops = { |
75 | static chardev_operations_t gxemul_ops = { |
74 | .resume = gxemul_enable, |
76 | .resume = gxemul_enable, |
75 | .suspend = gxemul_disable, |
77 | .suspend = gxemul_disable, |
76 | .write = gxemul_write, |
78 | .write = gxemul_write, |
77 | .read = gxemul_do_read, |
79 | .read = gxemul_do_read, |
78 | }; |
80 | }; |
79 | 81 | ||
80 | 82 | ||
81 | /** Initializes #gxemul_hw_map. */ |
83 | /** Initializes #gxemul_hw_map. */ |
82 | void gxemul_hw_map_init(void) |
84 | void gxemul_hw_map_init(void) |
83 | { |
85 | { |
84 | gxemul_hw_map.videoram = hw_map(GXEMUL_VIDEORAM, PAGE_SIZE); |
86 | gxemul_hw_map.videoram = hw_map(GXEMUL_VIDEORAM, PAGE_SIZE); |
85 | gxemul_hw_map.kbd = hw_map(GXEMUL_KBD, PAGE_SIZE); |
87 | gxemul_hw_map.kbd = hw_map(GXEMUL_KBD, PAGE_SIZE); |
86 | gxemul_hw_map.rtc = hw_map(GXEMUL_RTC, PAGE_SIZE); |
88 | gxemul_hw_map.rtc = hw_map(GXEMUL_RTC, PAGE_SIZE); |
87 | gxemul_hw_map.irqc = hw_map(GXEMUL_IRQC, PAGE_SIZE); |
89 | gxemul_hw_map.irqc = hw_map(GXEMUL_IRQC, PAGE_SIZE); |
88 | 90 | ||
89 | gxemul_hw_map.rtc_freq = gxemul_hw_map.rtc + GXEMUL_RTC_FREQ_OFFSET; |
91 | gxemul_hw_map.rtc_freq = gxemul_hw_map.rtc + GXEMUL_RTC_FREQ_OFFSET; |
90 | gxemul_hw_map.rtc_ack = gxemul_hw_map.rtc + GXEMUL_RTC_ACK_OFFSET; |
92 | gxemul_hw_map.rtc_ack = gxemul_hw_map.rtc + GXEMUL_RTC_ACK_OFFSET; |
91 | gxemul_hw_map.irqc_mask = gxemul_hw_map.irqc + GXEMUL_IRQC_MASK_OFFSET; |
93 | gxemul_hw_map.irqc_mask = gxemul_hw_map.irqc + GXEMUL_IRQC_MASK_OFFSET; |
92 | gxemul_hw_map.irqc_unmask = gxemul_hw_map.irqc + GXEMUL_IRQC_UNMASK_OFFSET; |
94 | gxemul_hw_map.irqc_unmask = gxemul_hw_map.irqc + GXEMUL_IRQC_UNMASK_OFFSET; |
93 | 95 | ||
- | 96 | hw_map_init_called = true; |
|
94 | } |
97 | } |
95 | 98 | ||
96 | /** Putchar that works with gxemul */ |
99 | /** Putchar that works with gxemul */ |
97 | void gxemul_write(chardev_t *dev, const char ch) |
100 | void gxemul_write(chardev_t *dev, const char ch) |
98 | { |
101 | { |
99 | *((char *) gxemul_hw_map.videoram) = ch; |
102 | *((char *) gxemul_hw_map.videoram) = ch; |
100 | } |
103 | } |
101 | 104 | ||
102 | /* Called from getc(). */ |
105 | /* Called from getc(). */ |
103 | void gxemul_enable(chardev_t *dev) |
106 | void gxemul_enable(chardev_t *dev) |
104 | { |
107 | { |
105 | // cp0_unmask_int(GXEMUL_KBD_IRQ); |
108 | // cp0_unmask_int(GXEMUL_KBD_IRQ); |
106 | gxemul_irqc_unmask(GXEMUL_KBD_IRQ); |
109 | gxemul_irqc_unmask(GXEMUL_KBD_IRQ); |
107 | } |
110 | } |
108 | 111 | ||
109 | /* Called from getc(). */ |
112 | /* Called from getc(). */ |
110 | void gxemul_disable(chardev_t *dev) |
113 | void gxemul_disable(chardev_t *dev) |
111 | { |
114 | { |
112 | // cp0_mask_int(GXEMUL_KBD_IRQ); |
115 | // cp0_mask_int(GXEMUL_KBD_IRQ); |
113 | gxemul_irqc_mask(GXEMUL_KBD_IRQ); |
116 | gxemul_irqc_mask(GXEMUL_KBD_IRQ); |
114 | } |
117 | } |
115 | 118 | ||
116 | /** Read character using polling, assume interrupts disabled */ |
119 | /** Read character using polling, assume interrupts disabled */ |
117 | static char gxemul_do_read(chardev_t *dev) |
120 | static char gxemul_do_read(chardev_t *dev) |
118 | { |
121 | { |
119 | char ch; |
122 | char ch; |
120 | 123 | ||
121 | while (1) { |
124 | while (1) { |
122 | ch = *((volatile char *) gxemul_hw_map.kbd); |
125 | ch = *((volatile char *) gxemul_hw_map.kbd); |
123 | if (ch) { |
126 | if (ch) { |
124 | if (ch == '\r') |
127 | if (ch == '\r') |
125 | return '\n'; |
128 | return '\n'; |
126 | if (ch == 0x7f) |
129 | if (ch == 0x7f) |
127 | return '\b'; |
130 | return '\b'; |
128 | return ch; |
131 | return ch; |
129 | } |
132 | } |
130 | } |
133 | } |
131 | } |
134 | } |
132 | 135 | ||
133 | /** Process keyboard interrupt. */ |
136 | /** Process keyboard interrupt. */ |
134 | static void gxemul_irq_handler(irq_t *irq, void *arg, ...) |
137 | static void gxemul_irq_handler(irq_t *irq, void *arg, ...) |
135 | { |
138 | { |
136 | if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) |
139 | if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox)) |
137 | ipc_irq_send_notif(irq); |
140 | ipc_irq_send_notif(irq); |
138 | else { |
141 | else { |
139 | char ch = 0; |
142 | char ch = 0; |
140 | 143 | ||
141 | ch = *((char *) gxemul_hw_map.kbd); |
144 | ch = *((char *) gxemul_hw_map.kbd); |
142 | if (ch =='\r') |
145 | if (ch =='\r') |
143 | ch = '\n'; |
146 | ch = '\n'; |
144 | if (ch == 0x7f) |
147 | if (ch == 0x7f) |
145 | ch = '\b'; |
148 | ch = '\b'; |
146 | chardev_push_character(&console, ch); |
149 | chardev_push_character(&console, ch); |
147 | } |
150 | } |
148 | } |
151 | } |
149 | 152 | ||
150 | static irq_ownership_t gxemul_claim(void) |
153 | static irq_ownership_t gxemul_claim(void) |
151 | { |
154 | { |
152 | return IRQ_ACCEPT; |
155 | return IRQ_ACCEPT; |
153 | } |
156 | } |
154 | 157 | ||
155 | void machine_grab_console(void) |
158 | void machine_grab_console(void) |
156 | { |
159 | { |
157 | ipl_t ipl = interrupts_disable(); |
160 | ipl_t ipl = interrupts_disable(); |
158 | spinlock_lock(&gxemul_irq.lock); |
161 | spinlock_lock(&gxemul_irq.lock); |
159 | gxemul_irq.notif_cfg.notify = false; |
162 | gxemul_irq.notif_cfg.notify = false; |
160 | spinlock_unlock(&gxemul_irq.lock); |
163 | spinlock_unlock(&gxemul_irq.lock); |
161 | interrupts_restore(ipl); |
164 | interrupts_restore(ipl); |
162 | } |
165 | } |
163 | 166 | ||
164 | void machine_release_console(void) |
167 | void machine_release_console(void) |
165 | { |
168 | { |
166 | ipl_t ipl = interrupts_disable(); |
169 | ipl_t ipl = interrupts_disable(); |
167 | spinlock_lock(&gxemul_irq.lock); |
170 | spinlock_lock(&gxemul_irq.lock); |
168 | if (gxemul_irq.notif_cfg.answerbox) |
171 | if (gxemul_irq.notif_cfg.answerbox) |
169 | gxemul_irq.notif_cfg.notify = true; |
172 | gxemul_irq.notif_cfg.notify = true; |
170 | spinlock_unlock(&gxemul_irq.lock); |
173 | spinlock_unlock(&gxemul_irq.lock); |
171 | interrupts_restore(ipl); |
174 | interrupts_restore(ipl); |
172 | } |
175 | } |
173 | 176 | ||
174 | 177 | ||
175 | /** Return console object representing gxemul console */ |
178 | /** Return console object representing gxemul console */ |
176 | void machine_console_init(devno_t devno) |
179 | void machine_console_init(devno_t devno) |
177 | { |
180 | { |
178 | chardev_initialize("gxemul_console", &console, &gxemul_ops); |
181 | chardev_initialize("gxemul_console", &console, &gxemul_ops); |
179 | stdin = &console; |
182 | stdin = &console; |
180 | stdout = &console; |
183 | stdout = &console; |
181 | 184 | ||
182 | irq_initialize(&gxemul_irq); |
185 | irq_initialize(&gxemul_irq); |
183 | gxemul_irq.devno = devno; |
186 | gxemul_irq.devno = devno; |
184 | gxemul_irq.inr = GXEMUL_KBD_IRQ; |
187 | gxemul_irq.inr = GXEMUL_KBD_IRQ; |
185 | gxemul_irq.claim = gxemul_claim; |
188 | gxemul_irq.claim = gxemul_claim; |
186 | gxemul_irq.handler = gxemul_irq_handler; |
189 | gxemul_irq.handler = gxemul_irq_handler; |
187 | irq_register(&gxemul_irq); |
190 | irq_register(&gxemul_irq); |
188 | 191 | ||
189 | // cp0_unmask_int(GXEMUL_KBD_IRQ); |
192 | // cp0_unmask_int(GXEMUL_KBD_IRQ); |
190 | gxemul_irqc_unmask(GXEMUL_KBD_IRQ); |
193 | gxemul_irqc_unmask(GXEMUL_KBD_IRQ); |
191 | 194 | ||
192 | sysinfo_set_item_val("kbd", NULL, true); |
195 | sysinfo_set_item_val("kbd", NULL, true); |
193 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
196 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
194 | sysinfo_set_item_val("kbd.inr", NULL, GXEMUL_KBD_IRQ); |
197 | sysinfo_set_item_val("kbd.inr", NULL, GXEMUL_KBD_IRQ); |
195 | sysinfo_set_item_val("kbd.address.virtual", NULL, gxemul_hw_map.kbd); |
198 | sysinfo_set_item_val("kbd.address.virtual", NULL, gxemul_hw_map.kbd); |
196 | } |
199 | } |
197 | 200 | ||
198 | /** Return the mask of active interrupts. */ |
201 | /** Return the mask of active interrupts. */ |
199 | inline uint32_t gxemul_irqc_get_sources(void) |
202 | inline uint32_t gxemul_irqc_get_sources(void) |
200 | { |
203 | { |
201 | return *(uint32_t*) gxemul_hw_map.irqc; |
204 | return *(uint32_t*) gxemul_hw_map.irqc; |
202 | } |
205 | } |
203 | 206 | ||
204 | /** Masks interrupt. |
207 | /** Masks interrupt. |
205 | * |
208 | * |
206 | * @param irq interrupt number |
209 | * @param irq interrupt number |
207 | */ |
210 | */ |
208 | inline void gxemul_irqc_mask(uint32_t irq) |
211 | inline void gxemul_irqc_mask(uint32_t irq) |
209 | { |
212 | { |
210 | *(uint32_t*) gxemul_hw_map.irqc_mask = irq; |
213 | *(uint32_t*) gxemul_hw_map.irqc_mask = irq; |
211 | } |
214 | } |
212 | 215 | ||
213 | /** Unmasks interrupt. |
216 | /** Unmasks interrupt. |
214 | * |
217 | * |
215 | * @param irq interrupt number |
218 | * @param irq interrupt number |
216 | */ |
219 | */ |
217 | inline void gxemul_irqc_unmask(uint32_t irq) |
220 | inline void gxemul_irqc_unmask(uint32_t irq) |
218 | { |
221 | { |
219 | *(uint32_t*) gxemul_hw_map.irqc_unmask = irq; |
222 | *(uint32_t*) gxemul_hw_map.irqc_unmask = irq; |
220 | } |
223 | } |
221 | 224 | ||
222 | 225 | ||
223 | /** Starts gxemul Real Time Clock device, which asserts regular interrupts. |
226 | /** Starts gxemul Real Time Clock device, which asserts regular interrupts. |
224 | * |
227 | * |
225 | * @param frequency interrupts frequency (0 disables RTC) |
228 | * @param frequency interrupts frequency (0 disables RTC) |
226 | */ |
229 | */ |
227 | void gxemul_timer_start(uint32_t frequency) |
230 | void gxemul_timer_start(uint32_t frequency) |
228 | { |
231 | { |
229 | *(uint32_t*) gxemul_hw_map.rtc_freq = frequency; |
232 | *(uint32_t*) gxemul_hw_map.rtc_freq = frequency; |
230 | } |
233 | } |
231 | 234 | ||
232 | static irq_ownership_t gxemul_timer_claim(void) |
235 | static irq_ownership_t gxemul_timer_claim(void) |
233 | { |
236 | { |
234 | return IRQ_ACCEPT; |
237 | return IRQ_ACCEPT; |
235 | } |
238 | } |
236 | 239 | ||
237 | static void gxemul_timer_irq_handler(irq_t *irq, void *arg, ...) |
240 | static void gxemul_timer_irq_handler(irq_t *irq, void *arg, ...) |
238 | { |
241 | { |
239 | /* TODO time drifts ?? |
242 | /* TODO time drifts ?? |
240 | unsigned long drift; |
243 | unsigned long drift; |
241 | 244 | ||
242 | drift = cp0_count_read() - nextcount; |
245 | drift = cp0_count_read() - nextcount; |
243 | while (drift > cp0_compare_value) { |
246 | while (drift > cp0_compare_value) { |
244 | drift -= cp0_compare_value; |
247 | drift -= cp0_compare_value; |
245 | CPU->missed_clock_ticks++; |
248 | CPU->missed_clock_ticks++; |
246 | } |
249 | } |
247 | nextcount = cp0_count_read() + cp0_compare_value - drift; |
250 | nextcount = cp0_count_read() + cp0_compare_value - drift; |
248 | cp0_compare_write(nextcount); |
251 | cp0_compare_write(nextcount); |
249 | */ |
252 | */ |
250 | 253 | ||
251 | /* |
254 | /* |
252 | * We are holding a lock which prevents preemption. |
255 | * We are holding a lock which prevents preemption. |
253 | * Release the lock, call clock() and reacquire the lock again. |
256 | * Release the lock, call clock() and reacquire the lock again. |
254 | */ |
257 | */ |
255 | spinlock_unlock(&irq->lock); |
258 | spinlock_unlock(&irq->lock); |
256 | clock(); |
259 | clock(); |
257 | spinlock_lock(&irq->lock); |
260 | spinlock_lock(&irq->lock); |
258 | 261 | ||
259 | /* acknowledge tick */ |
262 | /* acknowledge tick */ |
260 | *(uint32_t*) gxemul_hw_map.rtc_ack = 0; |
263 | *(uint32_t*) gxemul_hw_map.rtc_ack = 0; |
261 | 264 | ||
262 | /* TODO what's that? * |
265 | /* TODO what's that? * |
263 | if (virtual_timer_fnc != NULL) |
266 | if (virtual_timer_fnc != NULL) |
264 | virtual_timer_fnc(); |
267 | virtual_timer_fnc(); |
265 | */ |
268 | */ |
266 | } |
269 | } |
267 | 270 | ||
268 | /** |
271 | /** |
269 | * Initializes and registers timer interrupt handler. |
272 | * Initializes and registers timer interrupt handler. |
270 | */ |
273 | */ |
271 | void gxemul_timer_irq_init() |
274 | void gxemul_timer_irq_init() |
272 | { |
275 | { |
273 | irq_initialize(&gxemul_timer_irq); |
276 | irq_initialize(&gxemul_timer_irq); |
274 | gxemul_timer_irq.devno = device_assign_devno(); |
277 | gxemul_timer_irq.devno = device_assign_devno(); |
275 | gxemul_timer_irq.inr = GXEMUL_TIMER_IRQ; |
278 | gxemul_timer_irq.inr = GXEMUL_TIMER_IRQ; |
276 | gxemul_timer_irq.claim = gxemul_timer_claim; |
279 | gxemul_timer_irq.claim = gxemul_timer_claim; |
277 | gxemul_timer_irq.handler = gxemul_timer_irq_handler; |
280 | gxemul_timer_irq.handler = gxemul_timer_irq_handler; |
278 | 281 | ||
279 | irq_register(&gxemul_timer_irq); |
282 | irq_register(&gxemul_timer_irq); |
280 | } |
283 | } |
281 | 284 | ||
282 | void machine_timer_irq_start() |
285 | void machine_timer_irq_start() |
283 | { |
286 | { |
284 | gxemul_timer_irq_init(); |
287 | gxemul_timer_irq_init(); |
285 | gxemul_timer_start(GXEMUL_TIMER_FREQ); |
288 | gxemul_timer_start(GXEMUL_TIMER_FREQ); |
286 | } |
289 | } |
287 | 290 | ||
288 | size_t machine_get_memory_size(void) |
291 | size_t machine_get_memory_size(void) |
289 | { |
292 | { |
290 | return *((int*)(GXEMUL_MP + GXEMUL_MP_MEMSIZE_OFFSET)); |
293 | return *((int*)(GXEMUL_MP + GXEMUL_MP_MEMSIZE_OFFSET)); |
291 | } |
294 | } |
292 | 295 | ||
293 | void gxemul_debug_putc(char ch) { |
296 | void machine_debug_putc(char ch) { |
- | 297 | if (!hw_map_init_called) { |
|
294 | // *((volatile char *) GXEMUL_KBD) = ch; |
298 | *((volatile char *) GXEMUL_KBD) = ch; |
295 | //TODO commented version doesn't work, don't know why (as ?? |
299 | } else { |
296 | *((char *) gxemul_hw_map.videoram) = ch; |
300 | *((char *) gxemul_hw_map.videoram) = ch; |
- | 301 | } |
|
297 | } |
302 | } |
298 | 303 | ||
299 | /** @} |
304 | /** @} |
300 | */ |
305 | */ |
301 | 306 |