Subversion Repositories HelenOS

Rev

Rev 3759 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3759 Rev 4612
Line 50... Line 50...
50
/* Addresses of devices. */
50
/* Addresses of devices. */
51
#define QEMU_ICP_VIDEORAM            0x16000000
51
#define QEMU_ICP_VIDEORAM            0x16000000
52
#define QEMU_ICP_KBD                 0x18000000
52
#define QEMU_ICP_KBD                 0x18000000
53
#define QEMU_ICP_HALT_OFFSET         0x10
53
#define QEMU_ICP_HALT_OFFSET         0x10
54
#define QEMU_ICP_RTC                 0x13000000
54
#define QEMU_ICP_RTC                 0x13000000
-
 
55
#define QEMU_ICP_RTC1_LOAD_OFFSET    0x100
55
#define QEMU_ICP_RTC_FREQ_OFFSET     0x100
56
#define QEMU_ICP_RTC1_READ_OFFSET    0x104
56
#define QEMU_ICP_RTC_ACK_OFFSET      0x110
57
#define QEMU_ICP_RTC1_CTL_OFFSET     0x108
-
 
58
#define QEMU_ICP_RTC1_INTRCLR_OFFSET 0x10C
-
 
59
#define QEMU_ICP_RTC1_BGLOAD_OFFSET  0x118
-
 
60
#define QEMU_ICP_RTC_CTL_VALUE       0x00E2
57
#define QEMU_ICP_IRQC                0x14000000
61
#define QEMU_ICP_IRQC                0x14000000
58
#define QEMU_ICP_IRQC_MASK_OFFSET    0xC
62
#define QEMU_ICP_IRQC_MASK_OFFSET    0xC
59
#define QEMU_ICP_IRQC_UNMASK_OFFSET  0x8
63
#define QEMU_ICP_IRQC_UNMASK_OFFSET  0x8
60
#define QEMU_ICP_MP                  0x11000000
64
#define QEMU_ICP_MP                  0x11000000
61
#define QEMU_ICP_MP_MEMSIZE_OFFSET   0x0090
65
#define QEMU_ICP_MP_MEMSIZE_OFFSET   0x0090
Line 63... Line 67...
63
 
67
 
64
#define ICP_VGA              0xC0000000
68
#define ICP_VGA              0xC0000000
65
#define ICP_CMCR             0x10000000
69
#define ICP_CMCR             0x10000000
66
 
70
 
67
/* IRQs */
71
/* IRQs */
68
#define QEMU_ICP_KBD_IRQ        0x03
72
#define QEMU_ICP_KBD_IRQ        3
69
#define QEMU_ICP_TIMER_IRQ      0x05
73
#define QEMU_ICP_TIMER_IRQ      6
70
 
74
 
71
static qemu_icp_hw_map_t qemu_icp_hw_map;
75
static qemu_icp_hw_map_t qemu_icp_hw_map;
72
static chardev_t console;
76
static chardev_t console;
73
static irq_t qemu_icp_console_irq;
77
static irq_t qemu_icp_console_irq;
74
static irq_t qemu_icp_timer_irq;
78
static irq_t qemu_icp_timer_irq;
Line 116... Line 120...
116
 *
120
 *
117
 * @param irq interrupt number
121
 * @param irq interrupt number
118
 */
122
 */
119
static inline void qemu_icp_irqc_mask(uint32_t irq)
123
static inline void qemu_icp_irqc_mask(uint32_t irq)
120
{
124
{
121
    *((uint32_t *) qemu_icp_hw_map.irqc_mask) = irq;
125
    *((uint32_t *) qemu_icp_hw_map.irqc_mask) = (1 << irq);
122
}
126
}
123
 
127
 
124
 
128
 
125
/** Unmasks interrupt.
129
/** Unmasks interrupt.
126
 *
130
 *
127
 * @param irq interrupt number
131
 * @param irq interrupt number
128
 */
132
 */
129
static inline void qemu_icp_irqc_unmask(uint32_t irq)
133
static inline void qemu_icp_irqc_unmask(uint32_t irq)
130
{
134
{
131
    *((uint32_t *) qemu_icp_hw_map.irqc_unmask) |= irq;
135
    *((uint32_t *) qemu_icp_hw_map.irqc_unmask) |= (1 << irq);
132
}
136
}
133
 
137
 
134
/** Initializes the icp frame buffer */
138
/** Initializes the icp frame buffer */
135
void qemu_icp_fb_init(void)
139
void qemu_icp_fb_init(void)
136
{
140
{
Line 141... Line 145...
141
void qemu_icp_hw_map_init(void)
145
void qemu_icp_hw_map_init(void)
142
{
146
{
143
    qemu_icp_hw_map.videoram = hw_map(QEMU_ICP_VIDEORAM, PAGE_SIZE);
147
    qemu_icp_hw_map.videoram = hw_map(QEMU_ICP_VIDEORAM, PAGE_SIZE);
144
    qemu_icp_hw_map.kbd = hw_map(QEMU_ICP_KBD, PAGE_SIZE);
148
    qemu_icp_hw_map.kbd = hw_map(QEMU_ICP_KBD, PAGE_SIZE);
145
    qemu_icp_hw_map.rtc = hw_map(QEMU_ICP_RTC, PAGE_SIZE);
149
    qemu_icp_hw_map.rtc = hw_map(QEMU_ICP_RTC, PAGE_SIZE);
-
 
150
    qemu_icp_hw_map.rtc1_load = qemu_icp_hw_map.rtc + QEMU_ICP_RTC1_LOAD_OFFSET;
-
 
151
    qemu_icp_hw_map.rtc1_read = qemu_icp_hw_map.rtc + QEMU_ICP_RTC1_READ_OFFSET;
146
    qemu_icp_hw_map.irqc = hw_map(QEMU_ICP_IRQC, PAGE_SIZE);
152
    qemu_icp_hw_map.rtc1_ctl = qemu_icp_hw_map.rtc + QEMU_ICP_RTC1_CTL_OFFSET;
-
 
153
    qemu_icp_hw_map.rtc1_intrclr = qemu_icp_hw_map.rtc + QEMU_ICP_RTC1_INTRCLR_OFFSET;
-
 
154
    qemu_icp_hw_map.rtc1_bgload = qemu_icp_hw_map.rtc + QEMU_ICP_RTC1_BGLOAD_OFFSET;
147
 
155
 
148
    qemu_icp_hw_map.rtc_freq = qemu_icp_hw_map.rtc + QEMU_ICP_RTC_FREQ_OFFSET;
-
 
149
    qemu_icp_hw_map.rtc_ack = qemu_icp_hw_map.rtc + QEMU_ICP_RTC_ACK_OFFSET;
156
    qemu_icp_hw_map.irqc = hw_map(QEMU_ICP_IRQC, PAGE_SIZE);
150
    qemu_icp_hw_map.irqc_mask = qemu_icp_hw_map.irqc + QEMU_ICP_IRQC_MASK_OFFSET;
157
    qemu_icp_hw_map.irqc_mask = qemu_icp_hw_map.irqc + QEMU_ICP_IRQC_MASK_OFFSET;
151
    qemu_icp_hw_map.irqc_unmask = qemu_icp_hw_map.irqc +
158
    qemu_icp_hw_map.irqc_unmask = qemu_icp_hw_map.irqc +
152
        QEMU_ICP_IRQC_UNMASK_OFFSET;
159
        QEMU_ICP_IRQC_UNMASK_OFFSET;
153
    qemu_icp_hw_map.cmcr = hw_map(ICP_CMCR, PAGE_SIZE);
160
    qemu_icp_hw_map.cmcr = hw_map(ICP_CMCR, PAGE_SIZE);
154
    qemu_icp_hw_map.vga = hw_map(ICP_VGA, PAGE_SIZE);
161
    qemu_icp_hw_map.vga = hw_map(ICP_VGA, PAGE_SIZE);
Line 291... Line 298...
291
 *
298
 *
292
 * @param frequency Interrupts frequency (0 disables RTC).
299
 * @param frequency Interrupts frequency (0 disables RTC).
293
 */
300
 */
294
static void qemu_icp_timer_start(uint32_t frequency)
301
static void qemu_icp_timer_start(uint32_t frequency)
295
{
302
{
296
    *((uint32_t*) qemu_icp_hw_map.rtc_freq) = frequency;
303
    *((uint32_t*) qemu_icp_hw_map.rtc1_load) = frequency;
-
 
304
    *((uint32_t*) qemu_icp_hw_map.rtc1_bgload) = frequency;
-
 
305
    qemu_icp_irqc_mask(QEMU_ICP_TIMER_IRQ);
-
 
306
    *((uint32_t*) qemu_icp_hw_map.rtc1_ctl) = QEMU_ICP_RTC_CTL_VALUE;
-
 
307
    qemu_icp_irqc_unmask(QEMU_ICP_TIMER_IRQ);
297
}
308
}
298
 
309
 
299
static irq_ownership_t qemu_icp_timer_claim(void)
310
static irq_ownership_t qemu_icp_timer_claim(void)
300
{
311
{
301
    return IRQ_ACCEPT;
312
    return IRQ_ACCEPT;
Line 315... Line 326...
315
    spinlock_unlock(&irq->lock);
326
    spinlock_unlock(&irq->lock);
316
    clock();
327
    clock();
317
    spinlock_lock(&irq->lock);
328
    spinlock_lock(&irq->lock);
318
 
329
 
319
    /* acknowledge tick */
330
    /* acknowledge tick */
320
    *((uint32_t*) qemu_icp_hw_map.rtc_ack) = 0;
331
    *((uint32_t*) qemu_icp_hw_map.rtc1_intrclr) = 0;
321
}
332
}
322
 
333
 
323
/** Initializes and registers timer interrupt handler. */
334
/** Initializes and registers timer interrupt handler. */
324
static void qemu_icp_timer_irq_init(void)
335
static void qemu_icp_timer_irq_init(void)
325
{
336
{