Project

General

Profile

Revision 149

changed main loop

View differences:

proj.c
5 5
#include <stdbool.h>
6 6
#include <stdint.h>
7 7

  
8
#include "i8254.h"
9
#include "kbc_macros.h"
10
#include "graphics_macros.h"
11
#include "proj_macros.h"
12
#include "errors.h"
8 13

  
14
#include "kbc.h"
15
#include "graphics.h"
16
#include "timer.h"
17
#include "keyboard.h"
18
#include "utils.h"
19

  
9 20
int main(int argc, char* argv[]) {
10 21

  
11 22
    lcf_set_language("EN-US");
......
21 32
    return 0;
22 33
}
23 34

  
24
static int print_usage() {
25
  printf("Usage: <mode - hex>\n");
35
int(proj_main_loop)(int argc, char *argv[]) {
26 36

  
27
  return 1;
28
}
37
    /// loop stuff
38
    int ipc_status, r;
39
    message msg;
40
    /// Keyboard interrupt handling
41
    uint8_t kbc_irq_bit = KBC_IRQ;
42
    int kbc_id = 0;
43
    int kbc_irq = BIT(kbc_irq_bit);
44
    if (subscribe_kbc_interrupt(kbc_irq_bit, &kbc_id)) {
45
        return 1;
46
    }
29 47

  
30
int(proj_main_loop)(int argc, char *argv[]) {
48
    /// Timer interrupt handling
49
    //const uint32_t frequency = sys_hz(); // Frequency asummed at 60Hz
50
    uint8_t timer_irq_bit = TIMER0_IRQ;
51
    int timer_id = 0;
52
    int timer_irq = BIT(timer_irq_bit);
53
    if(subscribe_timer_interrupt(timer_irq_bit, &timer_id)) {
54
        if (vg_exit()) printf("%s: vg_exit failed to exit to text mode.\n", __func__);
55
        if (free_memory_map()) {
56
            printf("%s: lm_free failed\n", __func__);
57
        }
58
        return 1;
59
    }
60

  
31 61
    /// cycle
32 62
    int good = 1;
33 63
    while (good) {
......
43 73
                        kbc_ih();
44 74
                        if (scancode[0] == ESC_BREAK_CODE) good = 0;
45 75
                    }
76
                    if (msg.m_notify.interrupts & timer_irq) { /* subscribed interrupt */
77
                        timer_int_handler();
78
                    }
46 79
                    break;
47 80
                default:
48 81
                    break; /* no other notifications expected: do nothing */
......
51 84
            /* no standart message expected: do nothing */
52 85
        }
53 86
    }
87

  
88
    // Unsubscribe Keyboard interrupts
89
    if (unsubscribe_interrupt(&kbc_id)) {
90
        return 1;
91
    };
92

  
93
    // Unsubscribe Timer Interrupts
94
    if (unsubscribe_interrupt(&timer_id)) {
95
        return 1;
96
    }
97

  
98
    return 0;
54 99
}

Also available in: Unified diff