diff options
author | Sven Schnelle <svens@stackframe.org> | 2019-09-11 17:36:20 +0200 |
---|---|---|
committer | Sven Schnelle <svens@stackframe.org> | 2019-09-11 17:38:40 +0200 |
commit | 82ad1afaf38d42b7c05b4559674026ab86707648 (patch) | |
tree | b8d76fa8cd35e105c32e7f2b8df5a1e3c0d023a3 | |
parent | c6d6b2295575e25c657216aced6c8c4bedc391e3 (diff) | |
download | seabios-hppa-82ad1afaf38d42b7c05b4559674026ab86707648.zip seabios-hppa-82ad1afaf38d42b7c05b4559674026ab86707648.tar.gz seabios-hppa-82ad1afaf38d42b7c05b4559674026ab86707648.tar.bz2 |
parisc: add LASI PS/2 emulation.
This adds emulation of the PS/2 Keyboard and Mouse port
found on LASI chips.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
-rw-r--r-- | Makefile.parisc | 4 | ||||
-rw-r--r-- | src/kbd.c | 5 | ||||
-rw-r--r-- | src/parisc/lasips2.c | 66 | ||||
-rw-r--r-- | src/parisc/lasips2.h | 17 |
4 files changed, 90 insertions, 2 deletions
diff --git a/Makefile.parisc b/Makefile.parisc index bc52737..1cffdc0 100644 --- a/Makefile.parisc +++ b/Makefile.parisc @@ -33,7 +33,7 @@ LD32BIT_FLAG:= SRCBOTH=output.c string.c block.c cdrom.c disk.c kbd.c \ serial.c sercon.c clock.c vgahooks.c \ apm.c cp437.c \ - hw/pci.c hw/rtc.c hw/dma.c hw/pic.c hw/ps2port.c hw/serialio.c \ + hw/pci.c hw/rtc.c hw/dma.c hw/pic.c hw/serialio.c \ hw/usb.c hw/usb-uhci.c hw/usb-ohci.c hw/usb-ehci.c \ hw/usb-hid.c hw/usb-msc.c hw/usb-uas.c \ hw/blockcmd.c hw/floppy.c hw/ata.c hw/ramdisk.c \ @@ -48,7 +48,7 @@ SRC32FLAT=$(SRCBOTH) post.c e820map.c romfile.c optionroms.c \ fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c \ hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \ hw/tpm_drivers.c hw/nvme.c \ - version.c parisc/malloc.c parisc/parisc.c parisc/sti.c + version.c parisc/malloc.c parisc/parisc.c parisc/sti.c parisc/lasips2.c DIRS=src src/hw src/fw vgasrc src/parisc # VGA src files @@ -63,11 +63,16 @@ dequeue_key(struct bregs *regs, int incr, int extended) if (buffer_head != buffer_tail) break; +#ifdef CONFIG_PARISC + regs->ax = 0; + return; +#else if (!incr) { regs->flags |= F_ZF; return; } yield_toirq(); +#endif } u16 keycode = GET_FARVAR(SEG_BDA, *(u16*)(buffer_head+0)); diff --git a/src/parisc/lasips2.c b/src/parisc/lasips2.c new file mode 100644 index 0000000..119c214 --- /dev/null +++ b/src/parisc/lasips2.c @@ -0,0 +1,66 @@ +/* LASI PS2 keyboard support code + * + * Copyright (C) 2019 Sven Schnelle <svens@stackframe.org> + * + * This file may be distributed under the terms of the GNU LGPLv2 license. + */ + +#include "bregs.h" +#include "autoconf.h" +#include "types.h" +#include "output.h" +#include "hw/ps2port.h" +#include "util.h" +#include "string.h" +#include "lasips2.h" + +int lasips2_kbd_in(char *c, int max) +{ + struct bregs regs; + volatile int count = 0; + + while((readl(LASIPS2_KBD_STATUS) & LASIPS2_KBD_STATUS_RBNE)) { + process_key(readb(LASIPS2_KBD_DATA)); + } + + while(count < max) { + memset(®s, 0, sizeof(regs)); + regs.ah = 0x10; + handle_16(®s); + if (!regs.ah) + break; + *c++ = regs.ah; + count++; + } + return count; +} + + +int ps2_kbd_command(int command, u8 *param) +{ + return 0; +} + +int lasips2_command(u16 cmd) +{ + while(readl(LASIPS2_KBD_STATUS) & LASIPS2_KBD_STATUS_TBNE) + udelay(10); + writeb(LASIPS2_KBD_DATA, cmd & 0xff); + + while(!(readl(LASIPS2_KBD_STATUS) & LASIPS2_KBD_STATUS_RBNE)) + udelay(10); + return readb(LASIPS2_KBD_DATA); +} + +void ps2port_setup(void) +{ + writeb(LASIPS2_KBD_RESET, 0); + udelay(1000); + writeb(LASIPS2_KBD_CONTROL, LASIPS2_KBD_CONTROL_EN); + lasips2_command(ATKBD_CMD_RESET_BAT); + lasips2_command(ATKBD_CMD_RESET_DIS); + lasips2_command(ATKBD_CMD_SSCANSET); + lasips2_command(0x01); + lasips2_command(ATKBD_CMD_ENABLE); + kbd_init(); +} diff --git a/src/parisc/lasips2.h b/src/parisc/lasips2.h new file mode 100644 index 0000000..efdd66b --- /dev/null +++ b/src/parisc/lasips2.h @@ -0,0 +1,17 @@ +#ifndef PARISC_LASIPS2_H +#define PARISC_LASIPS2_H + +void ps2port_setup(void); + +int lasips2_kbd_in(char *c, int max); + +#define LASIPS2_KBD_RESET ((void *)(LASI_PS2KBD_HPA+0x00)) +#define LASIPS2_KBD_DATA ((void *)(LASI_PS2KBD_HPA+0x04)) +#define LASIPS2_KBD_CONTROL ((void *)(LASI_PS2KBD_HPA+0x08)) +#define LASIPS2_KBD_STATUS ((void *)(LASI_PS2KBD_HPA+0x0c)) + +#define LASIPS2_KBD_CONTROL_EN 0x01 +#define LASIPS2_KBD_STATUS_RBNE 0x01 +#define LASIPS2_KBD_STATUS_TBNE 0x02 + +#endif |