Changeset afc12d0 in mainline


Ignore:
Timestamp:
2006-06-06T17:08:10Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a175a67
Parents:
3dcb108
Message:

basic ppc32 keyboard

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r3dcb108 rafc12d0  
    8181ifeq ($(CONFIG_VHPT),y)
    8282        DEFS += -DCONFIG_VHPT
     83endif
     84ifeq ($(CONFIG_POWEROFF),y)
     85        DEFS += -DCONFIG_POWEROFF
    8386endif
    8487ifeq ($(CONFIG_FB),y)
  • arch/ppc32/include/boot/boot.h

    r3dcb108 rafc12d0  
    7272
    7373typedef struct {
     74        __address addr;
     75        unsigned int size;
     76} keyboard_t;
     77
     78typedef struct {
    7479        taskmap_t taskmap;
    7580        memmap_t memmap;
    7681        screen_t screen;
     82        keyboard_t keyboard;
    7783} bootinfo_t;
    7884
  • arch/ppc32/include/drivers/cuda.h

    r3dcb108 rafc12d0  
    3131
    3232#include <arch/types.h>
     33#include <typedefs.h>
    3334
    3435#define CUDA_IRQ 10
    3536
    36 extern void cuda_init(void);
    37 extern void cuda_packet(const __u8 data);
     37extern void cuda_init(__address base, size_t size);
    3838
    3939#endif
  • arch/ppc32/src/drivers/cuda.c

    r3dcb108 rafc12d0  
    3333#include <arch/drivers/pic.h>
    3434#include <interrupt.h>
     35#include <stdarg.h>
    3536
    36 #define CUDA_PACKET 0x01
     37#define PACKET_ADB  0x00
     38#define PACKET_CUDA 0x01
     39#define PACKET_NULL 0xff
     40
    3741#define CUDA_POWERDOWN 0x0a
    3842
     
    4852
    4953
    50 static volatile __u8 *cuda = (__u8 *) 0xf2000000;
     54static volatile __u8 *cuda = NULL;
     55
     56
     57static char lchars[0x80] = {
     58        'a',  's',  'd',  'f',  'h',  'g',  'z',  'x',  'c',  'v',    0,  'b',  'q',  'w',  'e',  'r',
     59        'y',  't',  '1',  '2',  '3',  '4',  '6',  '5',  '=',  '9',  '7',  '-',  '8',  '0',  ']',  'o',
     60        'u',  '[',  'i',  'p',   13,  'l',  'j', '\'',  'k',  ';', '\\',  ',',  '/',  'n',  'm',  '.',
     61          9,   32,  '`',    8,    0,   27,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     62          0,  '.',    0,  '*',    0,  '+',    0,    0,    0,    0,    0,  '/',   13,    0,  '-',    0,
     63          0,    0,  '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',    0,  '8',  '9',    0,    0,    0,
     64          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     65          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0
     66};
     67
     68
     69static void send_packet(const __u8 kind, index_t count, ...)
     70{
     71        index_t i;
     72        va_list va;
     73       
     74        switch (kind) {
     75                case PACKET_NULL:
     76                        break;
     77                default:
     78                        cuda[B] = cuda[B] | TIP;
     79                        cuda[ACR] = cuda[ACR] | SR_OUT;
     80                        cuda[SR] = kind;
     81                        cuda[B] = cuda[B] & ~TIP;
     82                       
     83                        va_start(va, count);
     84                       
     85                        for (i = 0; i < count; i++) {
     86                                cuda[ACR] = cuda[ACR] | SR_OUT;
     87                                cuda[SR] = va_arg(va, int);
     88                                cuda[B] = cuda[B] | TACK;
     89                        }
     90                       
     91                        va_end(va);
     92                       
     93                        cuda[B] = cuda[B] | TIP;
     94        }
     95}
     96
     97
     98static void receive_packet(__u8 *kind, index_t count, __u8 data[])
     99{
     100        cuda[B] = cuda[B] & ~TIP;
     101        *kind = cuda[SR];
     102       
     103        index_t i;
     104        for (i = 0; i < count; i++)
     105                data[i] = cuda[SR];
     106       
     107        cuda[B] = cuda[B] | TIP;
     108}
    51109
    52110
     
    79137};
    80138
    81 #include <print.h>
     139
    82140static void cuda_irq(int n, istate_t *istate)
    83141{
    84         printf("Got cuda msg\n");
     142        __u8 kind;
     143        __u8 data[4];
     144       
     145        receive_packet(&kind, 4, data);
     146       
     147        if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c)) {
     148                __u8 key = data[2];
     149               
     150                if ((key & 0x80) != 0x80)
     151                        chardev_push_character(&kbrd, lchars[key & 0x7f]);
     152        }
    85153}
    86154
    87 void cuda_init(void)
     155
     156void cuda_init(__address base, size_t size)
    88157{
     158        cuda = (__u8 *) hw_map(base, size);
     159       
    89160        int_register(CUDA_IRQ, "cuda", cuda_irq);
    90161        pic_enable_interrupt(CUDA_IRQ);
     
    95166
    96167
    97 void cuda_packet(const __u8 data)
    98 {
    99         cuda[B] = cuda[B] | TIP;
    100         cuda[ACR] = cuda[ACR] | SR_OUT;
    101         cuda[SR] = CUDA_PACKET;
    102         cuda[B] = cuda[B] & ~TIP;
    103        
    104         cuda[ACR] = cuda[ACR] | SR_OUT;
    105         cuda[SR] = data;
    106         cuda[B] = cuda[B] | TACK;
    107        
    108         cuda[B] = cuda[B] | TIP;
    109 }
    110 
    111 
    112168void cpu_halt(void) {
    113169#ifdef CONFIG_POWEROFF
    114         cuda_packet(CUDA_POWERDOWN);
     170        send_packet(PACKET_CUDA, 1, CUDA_POWERDOWN);
    115171#else
     172        send_packet(PACKET_NULL, 0);
     173#endif
    116174        asm volatile (
    117175                "b 0\n"
    118176        );
    119 #endif
    120         cpu_sleep();
    121177}
  • arch/ppc32/src/ppc32.c

    r3dcb108 rafc12d0  
    6969                /* Initialize PIC */
    7070                pic_init();
    71        
    72                 cuda_init();
     71               
     72                cuda_init(bootinfo.keyboard.addr, bootinfo.keyboard.size);
     73               
    7374                /* Merge all zones to 1 big zone */
    7475                zone_merge_all();
Note: See TracChangeset for help on using the changeset viewer.