Changeset 30ab05f in mainline


Ignore:
Timestamp:
2006-02-27T20:33:36Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d87c3f3
Parents:
02f441c0
Message:

sparc64 work.
Very raw and fragile preliminary standalone keyboard support - polling mode only.
Because of a workaround in Simics, the scan codes are the same as on ia32.

Files:
1 added
1 deleted
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • arch/sparc64/Makefile.inc

    r02f441c0 r30ab05f  
    5858CONFIG_ASID_FIFO = y
    5959
     60## Compile with support for framebuffer.
     61#
     62
    6063CONFIG_FB = y
     64
     65## Compile with support for i8042 controller.
     66#
     67
     68CONFIG_I8042 = y
    6169
    6270ARCH_SOURCES = \
  • arch/sparc64/include/console.h

    r02f441c0 r30ab05f  
    3131
    3232extern void kofwinput(void *arg);
     33extern void kkbdpoll(void *arg);
    3334extern void ofw_sparc64_console_init(void);
    3435extern void standalone_sparc64_console_init(void);
  • arch/sparc64/include/drivers/i8042.h

    r02f441c0 r30ab05f  
    2727 */
    2828
    29 #ifndef __sparc64_KEYBOARD_H__
    30 #define __sparc64_KEYBOARD_H__
     29#ifndef __sparc64_I8042_H__
     30#define __sparc64_I8042_H__
     31
     32#include <arch/types.h>
    3133
    3234#define KBD_PHYS_ADDRESS        0x1fff8904000ULL
    3335#define KBD_VIRT_ADDRESS        0x00000d00000ULL
    3436
     37#define STATUS_REG      4
     38#define COMMAND_REG     4
     39#define DATA_REG        6
     40
     41static inline void i8042_data_write(__u8 data)
     42{
     43        ((__u8 *)(KBD_VIRT_ADDRESS))[DATA_REG] = data;
     44}
     45
     46static inline __u8 i8042_data_read(void)
     47{
     48        return ((volatile __u8 *)(KBD_VIRT_ADDRESS))[DATA_REG];
     49}
     50
     51static inline __u8 i8042_status_read(void)
     52{
     53        return ((volatile __u8 *)(KBD_VIRT_ADDRESS))[STATUS_REG];
     54}
     55
     56static inline void i8042_command_write(__u8 command)
     57{
     58        ((__u8 *)(KBD_VIRT_ADDRESS))[COMMAND_REG] = command;
     59}
     60
    3561#endif
  • arch/sparc64/include/interrupt.h

    r02f441c0 r30ab05f  
    3535#define IVT_FIRST       1
    3636
     37/* Dummy macros. */
     38#define IRQ_KBD         2
     39#define VECTOR_KBD      IRQ_KBD
     40
     41#define trap_virtual_enable_irqs(x)
     42#define trap_virtual_eoi()
     43
    3744extern void interrupt_register(int n, const char *name, iroutine f);
    3845
  • arch/sparc64/src/console.c

    r02f441c0 r30ab05f  
    3232#include <genarch/fb/fb.h>
    3333#include <arch/drivers/fb.h>
    34 #include <arch/drivers/keyboard.h>
     34#include <arch/drivers/i8042.h>
     35#include <genarch/i8042/i8042.h>
    3536#include <genarch/ofw/ofw.h>
    3637#include <console/chardev.h>
     
    4041#include <proc/thread.h>
    4142#include <synch/mutex.h>
     43
     44#define KEYBOARD_POLL_PAUSE     50000   /* 50ms */
    4245
    4346static void ofw_sparc64_putchar(chardev_t *d, const char ch);
     
    7477        stdin = NULL;
    7578        fb_init(FB_VIRT_ADDRESS, FB_X_RES, FB_Y_RES, FB_COLOR_DEPTH/8);
     79        i8042_init();
    7680}
    7781
     
    156160                        chardev_push_character(&ofw_sparc64_console, ch);
    157161                }
    158                 thread_usleep(25000);
     162                thread_usleep(KEYBOARD_POLL_PAUSE);
    159163        }
    160164}
     165
     166/** Kernel thread for polling keyboard.
     167 *
     168 * @param arg Ignored.
     169 */
     170void kkbdpoll(void *arg)
     171{
     172        while (1) {
     173                i8042_poll();           
     174                thread_usleep(KEYBOARD_POLL_PAUSE);
     175        }
     176}
  • arch/sparc64/src/mm/tlb.c

    r02f441c0 r30ab05f  
    4343
    4444#include <arch/drivers/fb.h>
    45 #include <arch/drivers/keyboard.h>
     45#include <arch/drivers/i8042.h>
    4646
    4747char *context_encoding[] = {
  • arch/sparc64/src/sparc64.c

    r02f441c0 r30ab05f  
    6262                panic("cannot create kofwinput\n");
    6363        thread_ready(t);
     64
     65        /*
     66         * Create thread that polls keyboard.
     67         */
     68        t = thread_create(kkbdpoll, NULL, TASK, 0);
     69        if (!t)
     70                panic("cannot create kkbdpoll\n");
     71        thread_ready(t);
    6472}
    6573
  • arch/sparc64/src/start.S

    r02f441c0 r30ab05f  
    102102        nop
    103103
     104        wrpr %r0, 0, %pil
     105
    104106        call main_bsp
    105107        nop
  • genarch/include/i8042/i8042.h

    r02f441c0 r30ab05f  
    4646
    4747extern void i8042_init(void);
     48extern void i8042_poll(void);
    4849
    4950#endif
  • genarch/src/i8042/i8042.c

    r02f441c0 r30ab05f  
    5353/*
    5454 * 60  Write 8042 Command Byte: next data byte written to port 60h is
    55  *     placed in 8042 command register.Format:
     55 *     placed in 8042 command register. Format:
    5656 *
    5757 *    |7|6|5|4|3|2|1|0|8042 Command Byte
     
    7474#define SPECIAL         '?'
    7575#define KEY_RELEASE     0x80
     76
     77/**
     78 * These codes read from i8042 data register are silently ignored.
     79 */
     80#define IGNORE_CODE     0x7f
    7681
    7782static void key_released(__u8 sc);
     
    262267
    263268static void i8042_interrupt(int n, void *stack);
     269static void i8042_wait(void);
    264270
    265271/** Initialize i8042. */
     
    267273{
    268274        exc_register(VECTOR_KBD, "i8042_interrupt", i8042_interrupt);
    269         while (i8042_status_read() & i8042_WAIT_MASK) {
    270                 /* wait */
    271         }
     275        i8042_wait();
    272276        i8042_command_write(i8042_SET_COMMAND);
    273         while (i8042_status_read() & i8042_WAIT_MASK) {
    274                 /* wait */
    275         }
     277        i8042_wait();
    276278        i8042_data_write(i8042_COMMAND);
     279        i8042_wait();
    277280
    278281        trap_virtual_enable_irqs(1<<IRQ_KBD);
     
    296299        else
    297300                key_pressed(x);
     301}
     302
     303/** Wait until the controller reads its data. */
     304void i8042_wait(void) {
     305        while (i8042_status_read() & i8042_WAIT_MASK) {
     306                /* wait */
     307        }
    298308}
    299309
     
    503513                        ;
    504514                x = i8042_data_read();
    505                 if (x & KEY_RELEASE)
    506                         key_released(x ^ KEY_RELEASE);
    507                 else
    508                         active_read_key_pressed(x);
     515                if (x != IGNORE_CODE) {
     516                        if (x & KEY_RELEASE)
     517                                key_released(x ^ KEY_RELEASE);
     518                        else
     519                                active_read_key_pressed(x);
     520                }
    509521        }
    510522        return ch;
    511523}
     524
     525/** Poll for key press and release events.
     526 *
     527 * This function can be used to implement keyboard polling.
     528 */
     529void i8042_poll(void)
     530{
     531        __u8 x;
     532
     533        while (((x = i8042_status_read() & i8042_BUFFER_FULL_MASK))) {
     534                x = i8042_data_read();
     535                if (x != IGNORE_CODE) {
     536                        if (x & KEY_RELEASE)
     537                                key_released(x ^ KEY_RELEASE);
     538                        else
     539                                key_pressed(x);
     540                }
     541        }
     542}
Note: See TracChangeset for help on using the changeset viewer.