Changeset 63530c62 in mainline for kernel/genarch/src/kbd/ns16550.c


Ignore:
Timestamp:
2006-10-14T19:31:03Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e3890b3f
Parents:
7dcf22a
Message:

Changes in ns16550 and z8530 drivers.
Add some stuff for IRQ notifications to irq_t.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/kbd/ns16550.c

    r7dcf22a r63530c62  
    11/*
    2  * Copyright (C) 2001-2004 Jakub Jermar
     2 * Copyright (C) 2001-2006 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    5353#define LSR_DATA_READY  0x01
    5454
     55/** Structure representing the ns16550. */
     56static ns16550_t ns16550;
     57
     58/** Structure for ns16550's IRQ. */
     59static irq_t ns16550_irq;
     60
    5561/*
    5662 * These codes read from ns16550 data register are silently ignored.
     
    8288}
    8389
    84 /** Initialize ns16550. */
    85 void ns16550_init(void)
     90/** Initialize ns16550.
     91 *
     92 * @param devno Device number.
     93 * @param inr Interrupt number.
     94 * @param vaddr Virtual address of device's registers.
     95 */
     96void ns16550_init(devno_t devno, inr_t inr, uintptr_t vaddr)
    8697{
    8798        ns16550_grab();
     
    89100        stdin = &kbrd;
    90101       
     102        ns16550.devno = devno;
     103        ns16550.reg = (uint8_t *) vaddr;
     104       
     105        irq_initialize(&ns16550_irq);
     106        ns16550_irq.devno = devno;
     107        ns16550_irq.inr = inr;
     108        ns16550_irq.claim = ns16550_claim;
     109        ns16550_irq.handler = ns16550_irq_handler;
     110        irq_register(&ns16550_irq);
     111       
    91112        sysinfo_set_item_val("kbd", NULL, true);
    92         sysinfo_set_item_val("kbd.irq", NULL, 0);
    93         sysinfo_set_item_val("kbd.address.virtual", NULL, (uintptr_t) kbd_virt_address);
     113        sysinfo_set_item_val("kbd.devno", NULL, devno);
     114        sysinfo_set_item_val("kbd.inr", NULL, inr);
     115        sysinfo_set_item_val("kbd.address.virtual", NULL, vaddr);
    94116       
    95         ns16550_ier_write(IER_ERBFI);                           /* enable receiver interrupt */
     117        ns16550_ier_write(&ns16550, IER_ERBFI);         /* enable receiver interrupt */
    96118       
    97         while (ns16550_lsr_read() & LSR_DATA_READY)
    98                 (void) ns16550_rbr_read();
     119        while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY)
     120                (void) ns16550_rbr_read(&ns16550);
    99121}
    100122
     
    130152        while(!(ch = active_read_buff_read())) {
    131153                uint8_t x;
    132                 while (!(ns16550_lsr_read() & LSR_DATA_READY))
     154                while (!(ns16550_lsr_read(&ns16550) & LSR_DATA_READY))
    133155                        ;
    134                 x = ns16550_rbr_read();
     156                x = ns16550_rbr_read(&ns16550);
    135157                if (x != IGNORE_CODE) {
    136158                        if (x & KEY_RELEASE)
     
    151173        uint8_t x;
    152174
    153         while (ns16550_lsr_read() & LSR_DATA_READY) {
    154                 x = ns16550_rbr_read();
     175        while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) {
     176                x = ns16550_rbr_read(&ns16550);
    155177                if (x != IGNORE_CODE) {
    156178                        if (x & KEY_RELEASE)
Note: See TracChangeset for help on using the changeset viewer.