---
# System prepended metadata

title: Untitled

---

TIMER
PRE- Funcoes util_sys_inb e util_get_MSB
1- Read Timer Configuration
    - Send Readback command
    - Get the Status byte
    - display and filter status byte with the enum
2- Set Timer frequency 
    - Send Readback command
    - Assemble control word (with readback command)
    - Send control word
    - Divisor = timerfreq / freq
    - Send divisor to timer (LSB then MSB)
3 - Timer_test_int (usar interrupts do timer pra contar tempo)
    - Subscribe timer (global hook, irq line and policy IRQ_REENABLE)
    - Define irq_set (activate irq line bit, 0 for timer 1 for keyboard)
    - Use while loop provided, when an Interrupt is received increment 
    counter. When counter%60 == 0 timer_print_elapsed_time will show 1       second. (60 because of default timer frequency).
    - Unsubscribe interupts (provide hook_id)
    
TIMER TESTE 2020
    - Assemble Control Word (select timer and units)
    - Send Control Word to control register
    - send interval time to timer, LSB followed by MSB
    - Subscribe (timer_irq, irq_reenable, hood_id)
    - Inside the interruption loop, check if the status register
    has a pending interruption. If so, call the final given function and end loop.
    - Unsubscribe (provide hook_id)
    
KEYBOARD
1 - kbd_Test_scan
    - Subscribe with irq_set (line),policy and hook
    - Use professor code, call kbc_ih() and kbc_print_scancode()
        -kbc_ih gets status and prints scancode
2 - kbd_test_poll
    - While scancode != KEY_ESC:
        - kbc_read
        - kbc_print_scancode
    - then reenable keyboard, send to input command register a read command, then read from it, then write that back with |bit(0)
