diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ed/if_ed.c | 1858 | ||||
-rw-r--r-- | sys/dev/ed/if_edreg.h | 840 | ||||
-rw-r--r-- | sys/dev/fdc/fdc.c | 899 | ||||
-rw-r--r-- | sys/dev/fdc/fdcreg.h | 72 | ||||
-rw-r--r-- | sys/dev/ic/i8237.h | 9 | ||||
-rw-r--r-- | sys/dev/ic/nec765.h | 71 | ||||
-rw-r--r-- | sys/dev/ic/ns16550.h | 50 | ||||
-rw-r--r-- | sys/dev/kbd/kbdtables.h | 856 | ||||
-rw-r--r-- | sys/dev/sio/sio.c | 1721 | ||||
-rw-r--r-- | sys/dev/sio/sioreg.h | 113 | ||||
-rw-r--r-- | sys/dev/speaker/spkr.c | 521 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.c | 2385 |
12 files changed, 0 insertions, 9395 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c deleted file mode 100644 index 4a693ef..0000000 --- a/sys/dev/ed/if_ed.c +++ /dev/null @@ -1,1858 +0,0 @@ -/* - * Device driver for National Semiconductor DS8390 based ethernet - * adapters. By David Greenman, 29-April-1993 - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - * - * Currently supports the Western Digital/SMC 8003 and 8013 series - * and the 3Com 3c503 - */ - -/* - * Modification history - * - * $Log: if_ed.c,v $ - * Revision 1.18 93/07/27 03:41:36 davidg - * removed unnecessary variable assignment in ed_reset() - * - * Revision 1.17 93/07/26 18:40:57 davidg - * Added include of systm.h to pick up inlined min/max/bcmp if you have - * them in cpufunc.h. Modified wait loop in reset to look a little better. - * Added read for talley counters to prevent an infinite loop on old - * 8003E's if they (the counters) overflow. - * - * Revision 1.16 93/07/25 14:27:12 davidg - * added parans to the previous fix so that it can cope with outb - * being a macro. - * - * Revision 1.15 93/07/25 14:07:56 davidg - * fixed logic problem where a 3c503 register was being written - * even if the board wasn't a 3Com. Wolfgang Solfrank pointed this - * out. - * - * Revision 1.14 93/07/20 15:24:25 davidg - * ommision for force 16bit case fixed from last patch - * - * Revision 1.13 93/07/20 15:13:55 davidg - * Added config file override for memsize by using 'iosiz'. Also added - * config flags overrides to force 8/16bit mode and disable the use of - * double xmit buffers. - * - * Revision 1.12 93/07/07 06:27:44 davidg - * moved call to bpfattach to after this drivers attach printf - - * improves readability of startup messages. - * - * Revision 1.11 93/06/27 03:07:01 davidg - * fixed bugs in the 3Com part of the probe routine that were uncovered by - * the previous fix. - * - * Revision 1.10 93/06/25 19:23:19 davidg - * fixed bug that caused erroneous 'Invalid irq configuration' message when - * no board is present (during autoconfiguration). - * - * Revision 1.9 93/06/23 03:48:14 davidg - * fixed minor typo introduced when cleaning up probe routine - * - * Revision 1.8 93/06/23 03:37:19 davidg - * cleaned up/added some comments. Also improved readability of a part of - * the probe routine. - * - * Revision 1.7 93/06/22 04:45:01 davidg - * (no additional changes) Second beta release - * - * Revision 1.6 93/06/22 04:40:35 davidg - * minor definition fix to ed_reset() - * - * Revision 1.5 93/06/22 04:37:39 davidg - * fixed some comments - * - * Revision 1.4 93/06/22 04:34:34 davidg - * added support to use the LLC0 'link-level control' flag - * to disable the tranceiver for AUI operation on 3Com boards. - * The default for this flag can be set in the kernel config - * file - 'flags 0x01' sets the flag (disables the tranceiver). - * - * Revision 1.3 93/06/17 03:57:28 davidg - * fixed some printf's - * - * Revision 1.2 93/06/17 03:26:49 davidg - * fixed 3c503 code to determine 8/16bit board - * changed attach printf to work with Interim-0.1.5 and NetBSD - * - * Revision 1.1 93/06/14 22:21:24 davidg - * Beta release of device driver for SMC/WD80x3 and 3C503 ethernet boards. - * - * - */ - -#include "ed.h" -#if NED > 0 -#include "bpfilter.h" - -#include "param.h" -#include "systm.h" -#include "errno.h" -#include "ioctl.h" -#include "mbuf.h" -#include "socket.h" -#include "syslog.h" - -#include "net/if.h" -#include "net/if_dl.h" -#include "net/if_types.h" -#include "net/netisr.h" - -#ifdef INET -#include "netinet/in.h" -#include "netinet/in_systm.h" -#include "netinet/in_var.h" -#include "netinet/ip.h" -#include "netinet/if_ether.h" -#endif - -#ifdef NS -#include "netns/ns.h" -#include "netns/ns_if.h" -#endif - -#if NBPFILTER > 0 -#include "net/bpf.h" -#include "net/bpfdesc.h" -#endif - -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/icu.h" -#include "i386/isa/if_edreg.h" - -#include "i386/include/pio.h" - - -/* - * ed_softc: per line info and status - */ -struct ed_softc { - struct arpcom arpcom; /* ethernet common */ - - char *type_str; /* pointer to type string */ - u_char vendor; /* interface vendor */ - u_char type; /* interface type code */ - - u_short vector; /* interrupt vector */ - u_short asic_addr; /* ASIC I/O bus address */ - u_short nic_addr; /* NIC (DS8390) I/O bus address */ - - caddr_t smem_start; /* shared memory start address */ - caddr_t smem_end; /* shared memory end address */ - u_long smem_size; /* total shared memory size */ - caddr_t smem_ring; /* start of RX ring-buffer (in smem) */ - - caddr_t bpf; /* BPF "magic cookie" */ - - u_char memwidth; /* width of access to card mem 8 or 16 */ - u_char xmit_busy; /* transmitter is busy */ - u_char txb_cnt; /* Number of transmit buffers */ - u_char txb_next; /* Pointer to next buffer ready to xmit */ - u_short txb_next_len; /* next xmit buffer length */ - u_char data_buffered; /* data has been buffered in interface memory */ - u_char tx_page_start; /* first page of TX buffer area */ - - u_char rec_page_start; /* first page of RX ring-buffer */ - u_char rec_page_stop; /* last page of RX ring-buffer */ - u_char next_packet; /* pointer to next unread RX packet */ -} ed_softc[NED]; - -int ed_attach(), ed_init(), edintr(), ed_ioctl(), ed_probe(), - ed_start(), ed_reset(), ed_watchdog(); - -static void ed_stop(); - -static inline void ed_rint(); -static inline void ed_xmit(); -static inline char *ed_ring_copy(); - -extern int ether_output(); - -struct isa_driver eddriver = { - ed_probe, - ed_attach, - "ed" -}; -/* - * Interrupt conversion table for WD/SMC ASIC - * (IRQ* are defined in icu.h) - */ -static unsigned short ed_intr_mask[] = { - IRQ9, - IRQ3, - IRQ5, - IRQ7, - IRQ10, - IRQ11, - IRQ15, - IRQ4 -}; - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 -#define ETHER_HDR_SIZE 14 - -/* - * Determine if the device is present - * - * on entry: - * a pointer to an isa_device struct - * on exit: - * NULL if device not found - * or # of i/o addresses used (if found) - */ -int -ed_probe(isa_dev) - struct isa_device *isa_dev; -{ - struct ed_softc *sc = &ed_softc[isa_dev->id_unit]; - int i, x; - u_int memsize; - u_char iptr, memwidth, sum, tmp; - - /* - * Setup initial i/o address for ASIC and NIC - */ - sc->asic_addr = isa_dev->id_iobase; - sc->vector = isa_dev->id_irq; - sc->smem_start = (caddr_t)isa_dev->id_maddr; - - /* - * Attempt to do a checksum over the station address PROM. - * This is mapped differently on the WD80x3 and 3C503, so if - * it fails, it might be a 3C503. There is a problem with - * this, though: some clone WD boards don't pass the - * checksum test. Danpex boards for one. We need to do - * additional checking for this case. - */ - for (sum = 0, i = 0; i < 8; ++i) { - sum += inb(sc->asic_addr + ED_WD_PROM + i); - } - - if (sum == ED_WD_ROM_CHECKSUM_TOTAL) { - goto type_WD80x3; - } else { - /* - * Do additional checking to make sure its a 3Com and - * not a broken WD clone - */ - goto type_3Com; - } - -type_WD80x3: - /* - * Looks like a WD/SMC board - */ - - sc->vendor = ED_VENDOR_WD_SMC; - sc->type = inb(sc->asic_addr + ED_WD_CARD_ID); - - sc->nic_addr = sc->asic_addr + ED_WD_NIC_OFFSET; - - /* reset card to force it into a known state. */ - outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST); - DELAY(100); - outb(sc->asic_addr + ED_WD_MSR, inb(sc->asic_addr + ED_WD_MSR) & ~ED_WD_MSR_RST); - /* wait in the case this card is reading it's EEROM */ - DELAY(5000); - - /* - * Set initial values for width/size. - */ - switch (sc->type) { - case ED_TYPE_WD8003S: - sc->type_str = "WD8003S"; - memsize = 8192; - memwidth = 8; - break; - case ED_TYPE_WD8003E: - sc->type_str = "WD8003E"; - memsize = 8192; - memwidth = 8; - break; - case ED_TYPE_WD8013EBT: - sc->type_str = "WD8013EBT"; - memsize = 16384; - memwidth = 16; - break; - case ED_TYPE_WD8013EB: /* also WD8003EP */ - if (inb(sc->asic_addr + ED_WD_ICR) - & ED_WD_ICR_16BIT) { - memwidth = 16; - memsize = 16384; - sc->type_str = "WD8013EB"; - } else { - sc->type_str = "WD8003EP"; - memsize = 8192; - memwidth = 8; - } - break; - case ED_TYPE_WD8013EBP: - sc->type_str = "WD8013EBP"; - memsize = 16384; - memwidth = 16; - break; - case ED_TYPE_WD8013EPC: - sc->type_str = "WD8013EPC"; - memsize = 16384; - memwidth = 16; - break; - default: - sc->type_str = "unknown"; - memsize = 8192; - memwidth = 8; - break; - } - /* - * Make some adjustments to initial values depending on what is - * found in the ICR. - */ - if ((memwidth==16) - && ((inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) { - memwidth = 8; - memsize = 8192; - } - if (inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_MSZ) { - memsize = 32768; - } - -#if ED_DEBUG - printf("type=%s memwidth=%d memsize=%d id_msize=%d\n", - sc->type_str,memwidth,memsize,isa_dev->id_msize); - for (i=0; i<8; i++) - printf("%x -> %x\n", i, inb(sc->asic_addr + i)); -#endif - /* - * Allow the user to override the autoconfiguration - */ - if (isa_dev->id_msize) - memsize = isa_dev->id_msize; - /* - * (note that if the user specifies both of the following flags - * that '8bit' mode intentionally has precedence) - */ - if (isa_dev->id_flags & ED_FLAGS_FORCE_16BIT_MODE) - memwidth = 16; - if (isa_dev->id_flags & ED_FLAGS_FORCE_8BIT_MODE) - memwidth = 8; - - /* - * Check 83C584 interrupt configuration register if this board has one - * XXX - we could also check the IO address register. But why - * bother...if we get past this, it *has* to be correct. - */ - if (sc->type & ED_WD_SOFTCONFIG) { - /* - * Assemble together the encoded interrupt number. - */ - iptr = (inb(isa_dev->id_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) | - ((inb(isa_dev->id_iobase + ED_WD_IRR) & - (ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5); - /* - * Translate it using translation table, and check for correctness. - */ - if (ed_intr_mask[iptr] != isa_dev->id_irq) { - printf("ed%d: kernel configured irq doesn't match board configured irq\n", - isa_dev->id_unit); - return(0); - } - /* - * Enable the interrupt. - */ - outb(isa_dev->id_iobase + ED_WD_IRR, - inb(isa_dev->id_iobase + ED_WD_IRR) | ED_WD_IRR_IEN); - } - - sc->memwidth = memwidth; - /* - * allocate one xmit buffer if < 16k, two buffers otherwise - */ - if ((memsize < 16384) || (isa_dev->id_msize & ED_FLAGS_NO_DOUBLE_BUFFERING)) { - sc->smem_ring = sc->smem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE); - sc->txb_cnt = 1; - sc->rec_page_start = ED_TXBUF_SIZE; - } else { - sc->smem_ring = sc->smem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE * 2); - sc->txb_cnt = 2; - sc->rec_page_start = ED_TXBUF_SIZE * 2; - } - sc->smem_size = memsize; - sc->smem_end = sc->smem_start + memsize; - sc->rec_page_stop = memsize / ED_PAGE_SIZE; - sc->tx_page_start = ED_WD_PAGE_OFFSET; - - /* - * Get station address from on-board ROM - */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->arpcom.ac_enaddr[i] = inb(sc->asic_addr + ED_WD_PROM + i); - - /* - * Set address and enable interface shared memory. - */ - outb(sc->asic_addr + ED_WD_MSR, ((kvtop(sc->smem_start) >> 13) & - ED_WD_MSR_ADDR) | ED_WD_MSR_MENB); - - /* - * Set upper address bits and 8/16 bit access to shared memory - */ - if (sc->type & ED_WD_SOFTCONFIG) { - if (memwidth == 8) { - outb(sc->asic_addr + ED_WD_LAAR, - ((kvtop(sc->smem_start) >> 19) & ED_WD_LAAR_ADDRHI)); - } else { - outb(sc->asic_addr + ED_WD_LAAR, - ED_WD_LAAR_L16EN | ED_WD_LAAR_M16EN | - ((kvtop(sc->smem_start) >> 19) & ED_WD_LAAR_ADDRHI)); - } - } - - /* - * Now zero memory and verify that it is clear - */ - bzero(sc->smem_start, memsize); - - for (i = 0; i < memsize; ++i) - if (sc->smem_start[i]) { - printf("ed%d: failed to clear shared memory at %x - check configuration\n", - isa_dev->id_unit, sc->smem_start + i); - - /* - * Disable 16 bit access to shared memory - */ - if (memwidth == 16) - outb(sc->asic_addr + ED_WD_LAAR, - inb(sc->asic_addr + ED_WD_LAAR) - & ~ED_WD_LAAR_M16EN); - - return(0); - } - - /* - * Disable 16bit access to shared memory - we leave it disabled so - * that 1) machines reboot properly when the board is set - * 16 bit mode and there are conflicting 8bit devices/ROMS - * in the same 128k address space as this boards shared - * memory. and 2) so that other 8 bit devices with shared - * memory can be used in this 128k region, too. - */ - if (memwidth == 16) - outb(sc->asic_addr + ED_WD_LAAR, inb(sc->asic_addr + ED_WD_LAAR) - & ~ED_WD_LAAR_M16EN); - - isa_dev->id_msize = memsize; - return (ED_WD_IO_PORTS); - -type_3Com: - /* - * Looks like a 3Com board - */ - - sc->vendor = ED_VENDOR_3COM; - sc->asic_addr = isa_dev->id_iobase + ED_3COM_ASIC_OFFSET; - sc->nic_addr = isa_dev->id_iobase + ED_3COM_NIC_OFFSET; - - sc->type_str = "3c503"; - - memsize = 8192; - - /* - * Verify that the kernel configured I/O address matches the board - * configured address - */ - switch (inb(sc->asic_addr + ED_3COM_BCFR)) { - case ED_3COM_BCFR_300: - if (isa_dev->id_iobase != 0x300) - return(0); - break; - case ED_3COM_BCFR_310: - if (isa_dev->id_iobase != 0x310) - return(0); - break; - case ED_3COM_BCFR_330: - if (isa_dev->id_iobase != 0x330) - return(0); - break; - case ED_3COM_BCFR_350: - if (isa_dev->id_iobase != 0x350) - return(0); - break; - case ED_3COM_BCFR_250: - if (isa_dev->id_iobase != 0x250) - return(0); - break; - case ED_3COM_BCFR_280: - if (isa_dev->id_iobase != 0x280) - return(0); - break; - case ED_3COM_BCFR_2A0: - if (isa_dev->id_iobase != 0x2a0) - return(0); - break; - case ED_3COM_BCFR_2E0: - if (isa_dev->id_iobase != 0x2e0) - return(0); - break; - default: - return(0); - } - - /* - * Verify that the kernel shared memory address matches the - * board configured address. - */ - switch (inb(sc->asic_addr + ED_3COM_PCFR)) { - case ED_3COM_PCFR_DC000: - if (kvtop(isa_dev->id_maddr) != 0xdc000) - return(0); - break; - case ED_3COM_PCFR_D8000: - if (kvtop(isa_dev->id_maddr) != 0xd8000) - return(0); - break; - case ED_3COM_PCFR_CC000: - if (kvtop(isa_dev->id_maddr) != 0xcc000) - return(0); - break; - case ED_3COM_PCFR_C8000: - if (kvtop(isa_dev->id_maddr) != 0xc8000) - return(0); - break; - default: - return(0); - } - - /* - * Reset NIC and ASIC - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_RST); - /* - * Wait for a while, then un-reset it - */ - DELAY(5000); - outb(sc->asic_addr + ED_3COM_CR, 0); - - /* - * Wait a bit for the NIC to recover from the reset - */ - DELAY(5000); - - /* - * The 3Com ASIC defaults to rather strange settings for the CR after - * a reset - it's important to set it so that the NIC I/O - * registers are mapped. The above setting of it to '0' only - * resets the reset condition - the CR is *not* set to zeros. - */ - outb(sc->asic_addr + ED_3COM_CR, 0); - - /* - * Determine if this is an 8bit or 16bit board - */ - - /* - * select page 0 registers - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP); - - /* - * Attempt to clear WTS bit. If it doesn't clear, then this is a - * 16bit board. - */ - outb(sc->nic_addr + ED_P0_DCR, 0); - - /* - * select page 2 registers - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_2|ED_CR_RD2|ED_CR_STP); - - /* - * The 3c503 forces the WTS bit to a one if this is a 16bit board - */ - if (inb(sc->nic_addr + ED_P2_DCR) & ED_DCR_WTS) - memwidth = 16; - else - memwidth = 8; - - /* - * select page 0 registers - */ - outb(sc->nic_addr + ED_P2_CR, ED_CR_RD2|ED_CR_STP); - - sc->txb_cnt = 1; - - sc->tx_page_start = ED_3COM_PAGE_OFFSET; - sc->rec_page_start = ED_TXBUF_SIZE + ED_3COM_PAGE_OFFSET; - sc->rec_page_stop = memsize / ED_PAGE_SIZE + ED_3COM_PAGE_OFFSET; - - sc->smem_size = memsize; - sc->smem_end = sc->smem_start + memsize; - sc->smem_ring = sc->smem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE); - - sc->memwidth = memwidth; - - /* - * Initialize GA page start/stop registers. Probably only needed - * if doing DMA, but what the hell. - */ - outb(sc->asic_addr + ED_3COM_PSTR, sc->rec_page_start); - outb(sc->asic_addr + ED_3COM_PSPR, sc->rec_page_stop); - - /* - * Set IRQ. 3c503 only allows a choice of irq 2-5. - */ - switch (isa_dev->id_irq) { - case IRQ2: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ2); - break; - case IRQ3: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ3); - break; - case IRQ4: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ4); - break; - case IRQ5: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ5); - break; - default: - printf("ed%d: Invalid irq configuration\n", isa_dev->id_unit); - return(0); - } - - /* - * Initialize GA configuration register. Set bank and enable smem. - */ - outb(sc->asic_addr + ED_3COM_GACFR, ED_3COM_GACFR_RSEL | - ED_3COM_GACFR_MBS0); - - /* - * Initialize "Vector Pointer" registers. These gawd-awful things - * are compared to 20 bits of the address on ISA, and if they - * match, the shared memory is disabled. We set them to - * 0xffff0...allegedly the reset vector. - */ - outb(sc->asic_addr + ED_3COM_VPTR2, 0xff); - outb(sc->asic_addr + ED_3COM_VPTR1, 0xff); - outb(sc->asic_addr + ED_3COM_VPTR0, 0x00); - - /* - * Get station address from on-board ROM - */ - /* - * First, map ethernet address PROM over the top of where the NIC - * registers normally appear. - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_EALO); - - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->arpcom.ac_enaddr[i] = inb(sc->nic_addr + i); - - /* - * Unmap PROM - select NIC registers. Tranceiver remains disabled at - * this point. It's enabled in ed_init so that the attach code - * is given a chance to set the default based on a compile-time - * config option - */ - outb(sc->asic_addr + ED_3COM_CR, 0); - -#if 0 -printf("Starting write\n"); -for (i = 0; i < 8192; ++i) - bzero(sc->smem_start, 8192); -printf("Done.\n"); -#endif -#if 0 -{ char test_buf[1024]; -printf("starting write\n"); - for (i = 0; i < 8*8192; ++i) - bcopy(test_buf, sc->smem_start, 1024); -printf("starting read\n"); - for (i = 0; i < 8*8192; ++i) - bcopy(sc->smem_start, test_buf, 1024); -printf("done.\n"); -} -#endif - - /* - * Zero memory and verify that it is clear - */ - bzero(sc->smem_start, memsize); - - for (i = 0; i < memsize; ++i) - if (sc->smem_start[i]) { - printf("ed%d: failed to clear shared memory at %x - check configuration\n", - isa_dev->id_unit, sc->smem_start + i); - return(0); - } - - isa_dev->id_msize = memsize; - return(ED_3COM_IO_PORTS); -} - -/* - * Install interface into kernel networking data structures - */ -int -ed_attach(isa_dev) - struct isa_device *isa_dev; -{ - struct ed_softc *sc = &ed_softc[isa_dev->id_unit]; - struct ifnet *ifp = &sc->arpcom.ac_if; - struct ifaddr *ifa; - struct sockaddr_dl *sdl; - - /* - * Set interface to stopped condition (reset) - */ - ed_stop(isa_dev->id_unit); - - /* - * Initialize ifnet structure - */ - ifp->if_unit = isa_dev->id_unit; - ifp->if_name = "ed" ; - ifp->if_mtu = ETHERMTU; - ifp->if_init = ed_init; - ifp->if_output = ether_output; - ifp->if_start = ed_start; - ifp->if_ioctl = ed_ioctl; - ifp->if_reset = ed_reset; - ifp->if_watchdog = ed_watchdog; - - /* - * Set default state for LLC0 flag (used to disable the tranceiver - * for AUI operation), based on compile-time config option. - */ - if (isa_dev->id_flags & ED_FLAGS_DISABLE_TRANCEIVER) - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS - | IFF_LLC0); - else - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS); - - /* - * Attach the interface - */ - if_attach(ifp); - - /* - * Search down the ifa address list looking for the AF_LINK type entry - */ - ifa = ifp->if_addrlist; - while ((ifa != 0) && (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) - ifa = ifa->ifa_next; - /* - * If we find an AF_LINK type entry we fill in the hardware address. - * This is useful for netstat(1) to keep track of which interface - * is which. - */ - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - /* - * Fill in the link-level address for this interface - */ - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); - } - - /* - * Print additional info when attached - */ - printf("ed%d: address %s, type %s (%dbit) %s\n", isa_dev->id_unit, - ether_sprintf(sc->arpcom.ac_enaddr), sc->type_str, - sc->memwidth, ((sc->vendor == ED_VENDOR_3COM) && - (ifp->if_flags & IFF_LLC0)) ? "tranceiver disabled" : ""); - - /* - * If BPF is in the kernel, call the attach for it - */ -#if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - -} - -/* - * Reset interface. - */ -int -ed_reset(unit) - int unit; -{ - int s; - - s = splnet(); - - /* - * Stop interface and re-initialize. - */ - ed_stop(unit); - ed_init(unit); - - (void) splx(s); -} - -/* - * Take interface offline. - */ -void -ed_stop(unit) - int unit; -{ - struct ed_softc *sc = &ed_softc[unit]; - int n = 5000; - - /* - * Stop everything on the interface, and select page 0 registers. - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP); - - /* - * Wait for interface to enter stopped state, but limit # of checks - * to 'n' (about 5ms). It shouldn't even take 5us on modern - * DS8390's, but just in case it's an old one. - */ - while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) == 0) && --n); - -} - -/* - * Device timeout/watchdog routine. Entered if the device neglects to - * generate an interrupt after a transmit has been started on it. - */ -int -ed_watchdog(unit) - int unit; -{ - log(LOG_ERR, "ed%d: device timeout\n", unit); - - ed_reset(unit); -} - -/* - * Initialize device. - */ -ed_init(unit) - int unit; -{ - struct ed_softc *sc = &ed_softc[unit]; - struct ifnet *ifp = &sc->arpcom.ac_if; - int i, s; - u_char command; - - - /* address not known */ - if (ifp->if_addrlist == (struct ifaddr *)0) return; - - /* - * Initialize the NIC in the exact order outlined in the NS manual. - * This init procedure is "mandatory"...don't change what or when - * things happen. - */ - s = splnet(); - - /* reset transmitter flags */ - sc->data_buffered = 0; - sc->xmit_busy = 0; - sc->arpcom.ac_if.if_timer = 0; - - sc->txb_next = 0; - - /* This variable is used below - don't move this assignment */ - sc->next_packet = sc->rec_page_start + 1; - - /* - * Set interface for page 0, Remote DMA complete, Stopped - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP); - - if (sc->memwidth == 16) { - /* - * Set FIFO threshold to 8, No auto-init Remote DMA, - * byte order=80x86, word-wide DMA xfers - */ - outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1|ED_DCR_WTS); - } else { - /* - * Same as above, but byte-wide DMA xfers - */ - outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1); - } - - /* - * Clear Remote Byte Count Registers - */ - outb(sc->nic_addr + ED_P0_RBCR0, 0); - outb(sc->nic_addr + ED_P0_RBCR1, 0); - - /* - * Enable reception of broadcast packets - */ - outb(sc->nic_addr + ED_P0_RCR, ED_RCR_AB); - - /* - * Place NIC in internal loopback mode - */ - outb(sc->nic_addr + ED_P0_TCR, ED_TCR_LB0); - - /* - * Initialize transmit/receive (ring-buffer) Page Start - */ - outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start); - outb(sc->nic_addr + ED_P0_PSTART, sc->rec_page_start); - - /* - * Initialize Receiver (ring-buffer) Page Stop and Boundry - */ - outb(sc->nic_addr + ED_P0_PSTOP, sc->rec_page_stop); - outb(sc->nic_addr + ED_P0_BNRY, sc->rec_page_start); - - /* - * Clear all interrupts. A '1' in each bit position clears the - * corresponding flag. - */ - outb(sc->nic_addr + ED_P0_ISR, 0xff); - - /* - * Enable the following interrupts: receive/transmit complete, - * receive/transmit error, and Receiver OverWrite. - * - * Counter overflow and Remote DMA complete are *not* enabled. - */ - outb(sc->nic_addr + ED_P0_IMR, - ED_IMR_PRXE|ED_IMR_PTXE|ED_IMR_RXEE|ED_IMR_TXEE|ED_IMR_OVWE); - - /* - * Program Command Register for page 1 - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STP); - - /* - * Copy out our station address - */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - outb(sc->nic_addr + ED_P1_PAR0 + i, sc->arpcom.ac_enaddr[i]); - -#if NBPFILTER > 0 - /* - * Initialize multicast address hashing registers to accept - * all multicasts (only used when in promiscuous mode) - */ - for (i = 0; i < 8; ++i) - outb(sc->nic_addr + ED_P1_MAR0 + i, 0xff); -#endif - - /* - * Set Current Page pointer to next_packet (initialized above) - */ - outb(sc->nic_addr + ED_P1_CURR, sc->next_packet); - - /* - * Set Command Register for page 0, Remote DMA complete, - * and interface Start. - */ - outb(sc->nic_addr + ED_P1_CR, ED_CR_RD2|ED_CR_STA); - - /* - * Take interface out of loopback - */ - outb(sc->nic_addr + ED_P0_TCR, 0); - - /* - * If this is a 3Com board, the tranceiver must be software enabled - * (there is no settable hardware default). - */ - if (sc->vendor == ED_VENDOR_3COM) { - if (ifp->if_flags & IFF_LLC0) { - outb(sc->asic_addr + ED_3COM_CR, 0); - } else { - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - } - } - - /* - * Set 'running' flag, and clear output active flag. - */ - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - /* - * ...and attempt to start output - */ - ed_start(ifp); - - (void) splx(s); -} - -/* - * This routine actually starts the transmission on the interface - */ -static inline void ed_xmit(ifp) - struct ifnet *ifp; -{ - struct ed_softc *sc = &ed_softc[ifp->if_unit]; - u_short len = sc->txb_next_len; - - /* - * Set NIC for page 0 register access - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* - * Set TX buffer start page - */ - outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start + - sc->txb_next * ED_TXBUF_SIZE); - - /* - * Set TX length - */ - outb(sc->nic_addr + ED_P0_TBCR0, len & 0xff); - outb(sc->nic_addr + ED_P0_TBCR1, len >> 8); - - /* - * Set page 0, Remote DMA complete, Transmit Packet, and *Start* - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_TXP|ED_CR_STA); - - sc->xmit_busy = 1; - sc->data_buffered = 0; - - /* - * Switch buffers if we are doing double-buffered transmits - */ - if ((sc->txb_next == 0) && (sc->txb_cnt > 1)) - sc->txb_next = 1; - else - sc->txb_next = 0; - - /* - * Set a timer just in case we never hear from the board again - */ - ifp->if_timer = 2; -} - -/* - * Start output on interface. - * We make two assumptions here: - * 1) that the current priority is set to splnet _before_ this code - * is called *and* is returned to the appropriate priority after - * return - * 2) that the IFF_OACTIVE flag is checked before this code is called - * (i.e. that the output part of the interface is idle) - */ -int -ed_start(ifp) - struct ifnet *ifp; -{ - struct ed_softc *sc = &ed_softc[ifp->if_unit]; - struct mbuf *m0, *m; - caddr_t buffer; - int len; - u_char laar_tmp; - -outloop: - /* - * See if there is room to send more data (i.e. one or both of the - * buffers is empty). - */ - if (sc->data_buffered) - if (sc->xmit_busy) { - /* - * No room. Indicate this to the outside world - * and exit. - */ - ifp->if_flags |= IFF_OACTIVE; - return; - } else { - /* - * Data is buffered, but we're not transmitting, so - * start the xmit on the buffered data. - * Note that ed_xmit() resets the data_buffered flag - * before returning. - */ - ed_xmit(ifp); - } - - IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m); - if (m == 0) { - /* - * The following isn't pretty; we are using the !OACTIVE flag to - * indicate to the outside world that we can accept an additional - * packet rather than that the transmitter is _actually_ - * active. Indeed, the transmitter may be active, but if we haven't - * filled the secondary buffer with data then we still want to - * accept more. - * Note that it isn't necessary to test the data_buffered flag - - * we wouldn't have tried to de-queue the packet in the first place - * if it was set. - */ - ifp->if_flags &= ~IFF_OACTIVE; - return; - } - - /* - * Copy the mbuf chain into the transmit buffer - */ - /* - * Enable 16bit access to shared memory on WD/SMC boards - */ - if (sc->memwidth == 16) - if (sc->vendor == ED_VENDOR_WD_SMC) { - laar_tmp = inb(sc->asic_addr + ED_WD_LAAR); - outb(sc->asic_addr + ED_WD_LAAR, laar_tmp | ED_WD_LAAR_M16EN); - } - - buffer = sc->smem_start + (sc->txb_next * ED_TXBUF_SIZE * ED_PAGE_SIZE); - len = 0; - for (m0 = m; m != 0; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - - /* - * Restore previous shared mem access type - */ - if (sc->memwidth == 16) - if (sc->vendor == ED_VENDOR_WD_SMC) { - outb(sc->asic_addr + ED_WD_LAAR, laar_tmp); - } - - sc->txb_next_len = MAX(len, ETHER_MIN_LEN); - - if (sc->txb_cnt > 1) - /* - * only set 'buffered' flag if doing multiple buffers - */ - sc->data_buffered = 1; - - if (sc->xmit_busy == 0) - ed_xmit(ifp); - /* - * If there is BPF support in the configuration, tap off here. - * The following has support for converting trailer packets - * back to normal. - */ -#if NBPFILTER > 0 - if (sc->bpf) { - u_short etype; - int off, datasize, resid; - struct ether_header *eh; - struct trailer_header { - u_short ether_type; - u_short ether_residual; - } trailer_header; - char ether_packet[ETHER_MAX_LEN]; - char *ep; - - ep = ether_packet; - - /* - * We handle trailers below: - * Copy ether header first, then residual data, - * then data. Put all this in a temporary buffer - * 'ether_packet' and send off to bpf. Since the - * system has generated this packet, we assume - * that all of the offsets in the packet are - * correct; if they're not, the system will almost - * certainly crash in m_copydata. - * We make no assumptions about how the data is - * arranged in the mbuf chain (i.e. how much - * data is in each mbuf, if mbuf clusters are - * used, etc.), which is why we use m_copydata - * to get the ether header rather than assume - * that this is located in the first mbuf. - */ - /* copy ether header */ - m_copydata(m0, 0, sizeof(struct ether_header), ep); - eh = (struct ether_header *) ep; - ep += sizeof(struct ether_header); - etype = ntohs(eh->ether_type); - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) { - datasize = ((etype - ETHERTYPE_TRAIL) << 9); - off = datasize + sizeof(struct ether_header); - - /* copy trailer_header into a data structure */ - m_copydata(m0, off, sizeof(struct trailer_header), - &trailer_header.ether_type); - - /* copy residual data */ - m_copydata(m0, off+sizeof(struct trailer_header), - resid = ntohs(trailer_header.ether_residual) - - sizeof(struct trailer_header), ep); - ep += resid; - - /* copy data */ - m_copydata(m0, sizeof(struct ether_header), - datasize, ep); - ep += datasize; - - /* restore original ether packet type */ - eh->ether_type = trailer_header.ether_type; - - bpf_tap(sc->bpf, ether_packet, ep - ether_packet); - } else - bpf_mtap(sc->bpf, m0); - } -#endif - - m_freem(m0); - - /* - * If we are doing double-buffering, a buffer might be free to - * fill with another packet, so loop back to the top. - */ - if (sc->txb_cnt > 1) - goto outloop; - else { - ifp->if_flags |= IFF_OACTIVE; - return; - } -} - -/* - * Ethernet interface receiver interrupt. - */ -static inline void /* only called from one place, so may as well integrate */ -ed_rint(unit) - int unit; -{ - register struct ed_softc *sc = &ed_softc[unit]; - u_char boundry, current; - u_short len; - struct ed_ring *packet_ptr; - - /* - * Set NIC to page 1 registers to get 'current' pointer - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA); - - /* - * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e. - * it points to where new data has been buffered. The 'CURR' - * (current) register points to the logical end of the ring-buffer - * - i.e. it points to where additional new data will be added. - * We loop here until the logical beginning equals the logical - * end (or in other words, until the ring-buffer is empty). - */ - while (sc->next_packet != inb(sc->nic_addr + ED_P1_CURR)) { - - /* get pointer to this buffer header structure */ - packet_ptr = (struct ed_ring *)(sc->smem_ring + - (sc->next_packet - sc->rec_page_start) * ED_PAGE_SIZE); - - /* - * The byte count includes the FCS - Frame Check Sequence (a - * 32 bit CRC). - */ - len = packet_ptr->count; - if ((len >= ETHER_MIN_LEN) && (len <= ETHER_MAX_LEN)) { - /* - * Go get packet. len - 4 removes CRC from length. - * (packet_ptr + 1) points to data just after the packet ring - * header (+4 bytes) - */ - ed_get_packet(sc, (caddr_t)(packet_ptr + 1), len - 4); - ++sc->arpcom.ac_if.if_ipackets; - } else { - /* - * Really BAD...probably indicates that the ring pointers - * are corrupted. Also seen on early rev chips under - * high load - the byte order of the length gets switched. - */ - log(LOG_ERR, - "ed%d: shared memory corrupt - invalid packet length %d\n", - unit, len); - ed_reset(unit); - return; - } - - /* - * Update next packet pointer - */ - sc->next_packet = packet_ptr->next_packet; - - /* - * Update NIC boundry pointer - being careful to keep it - * one buffer behind. (as recommended by NS databook) - */ - boundry = sc->next_packet - 1; - if (boundry < sc->rec_page_start) - boundry = sc->rec_page_stop - 1; - - /* - * Set NIC to page 0 registers to update boundry register - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - outb(sc->nic_addr + ED_P0_BNRY, boundry); - - /* - * Set NIC to page 1 registers before looping to top (prepare to - * get 'CURR' current pointer) - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA); - } -} - -/* - * Ethernet interface interrupt processor - */ -int -edintr(unit) - int unit; -{ - struct ed_softc *sc = &ed_softc[unit]; - u_char isr; - - /* - * Set NIC to page 0 registers - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* - * loop until there are no more new interrupts - */ - while (isr = inb(sc->nic_addr + ED_P0_ISR)) { - - /* - * reset all the bits that we are 'acknowleging' - * by writing a '1' to each bit position that was set - * (writing a '1' *clears* the bit) - */ - outb(sc->nic_addr + ED_P0_ISR, isr); - - /* - * Transmit error. If a TX completed with an error, we end up - * throwing the packet away. Really the only error that is - * possible is excessive collisions, and in this case it is - * best to allow the automatic mechanisms of TCP to backoff - * the flow. Of course, with UDP we're screwed, but this is - * expected when a network is heavily loaded. - */ - if (isr & ED_ISR_TXE) { - u_char tsr = inb(sc->nic_addr + ED_P0_TSR); - u_char ncr = inb(sc->nic_addr + ED_P0_NCR); - - /* - * Excessive collisions (16) - */ - if ((tsr & ED_TSR_ABT) && (ncr == 0)) { - /* - * When collisions total 16, the P0_NCR will - * indicate 0, and the TSR_ABT is set. - */ - sc->arpcom.ac_if.if_collisions += 16; - } else - sc->arpcom.ac_if.if_collisions += ncr; - - /* - * update output errors counter - */ - ++sc->arpcom.ac_if.if_oerrors; - - /* - * reset tx busy and output active flags - */ - sc->xmit_busy = 0; - sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - /* - * clear watchdog timer - */ - sc->arpcom.ac_if.if_timer = 0; - } - - - /* - * Receiver Error. One or more of: CRC error, frame alignment error - * FIFO overrun, or missed packet. - */ - if (isr & ED_ISR_RXE) { - ++sc->arpcom.ac_if.if_ierrors; -#ifdef ED_DEBUG - printf("ed%d: receive error %x\n", unit, - inb(sc->nic_addr + ED_P0_RSR)); -#endif - } - - /* - * Overwrite warning. In order to make sure that a lockup - * of the local DMA hasn't occurred, we reset and - * re-init the NIC. The NSC manual suggests only a - * partial reset/re-init is necessary - but some - * chips seem to want more. The DMA lockup has been - * seen only with early rev chips - Methinks this - * bug was fixed in later revs. -DG - */ - if (isr & ED_ISR_OVW) { - ++sc->arpcom.ac_if.if_ierrors; - log(LOG_WARNING, - "ed%d: warning - receiver ring buffer overrun\n", - unit); - /* - * Stop/reset/re-init NIC - */ - ed_reset(unit); - } - - /* - * Transmission completed normally. - */ - if (isr & ED_ISR_PTX) { - - /* - * reset tx busy and output active flags - */ - sc->xmit_busy = 0; - sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - /* - * clear watchdog timer - */ - sc->arpcom.ac_if.if_timer = 0; - - /* - * Update total number of successfully transmitted - * packets. - */ - ++sc->arpcom.ac_if.if_opackets; - - /* - * Add in total number of collisions on last - * transmission. - */ - sc->arpcom.ac_if.if_collisions += inb(sc->nic_addr + - ED_P0_TBCR0); - } - - /* - * Receive Completion. Go and get the packet. - * XXX - Doing this on an error is dubious because there - * shouldn't be any data to get (we've configured the - * interface to not accept packets with errors). - */ - if (isr & (ED_ISR_PRX|ED_ISR_RXE)) { - /* - * Enable access to shared memory on WD/SMC boards - */ - if (sc->memwidth == 16) - if (sc->vendor == ED_VENDOR_WD_SMC) { - outb(sc->asic_addr + ED_WD_LAAR, - inb(sc->asic_addr + ED_WD_LAAR) - | ED_WD_LAAR_M16EN); - } - - ed_rint (unit); - - /* - * Disable access to shared memory - */ - if (sc->memwidth == 16) - if (sc->vendor == ED_VENDOR_WD_SMC) { - outb(sc->asic_addr + ED_WD_LAAR, - inb(sc->asic_addr + ED_WD_LAAR) - & ~ED_WD_LAAR_M16EN); - } - } - - /* - * If it looks like the transmitter can take more data, - * attempt to start output on the interface. If data is - * already buffered and ready to go, send it first. - */ - if ((sc->arpcom.ac_if.if_flags & IFF_OACTIVE) == 0) { - if (sc->data_buffered) - ed_xmit(&sc->arpcom.ac_if); - ed_start(&sc->arpcom.ac_if); - } - - /* - * return NIC CR to standard state: page 0, remote DMA complete, - * start (toggling the TXP bit off, even if was just set - * in the transmit routine, is *okay* - it is 'edge' - * triggered from low to high) - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* - * If the Network Talley Counters overflow, read them to - * reset them. It appears that old 8390's won't - * clear the ISR flag otherwise - resulting in an - * infinite loop. - */ - if (isr & ED_ISR_CNT) { - (void) inb(sc->nic_addr + ED_P0_CNTR0); - (void) inb(sc->nic_addr + ED_P0_CNTR1); - (void) inb(sc->nic_addr + ED_P0_CNTR2); - } - } -} - -/* - * Process an ioctl request. This code needs some work - it looks - * pretty ugly. - */ -int -ed_ioctl(ifp, command, data) - register struct ifnet *ifp; - int command; - caddr_t data; -{ - register struct ifaddr *ifa = (struct ifaddr *)data; - struct ed_softc *sc = &ed_softc[ifp->if_unit]; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splnet(); - - switch (command) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - ed_init(ifp->if_unit); /* before arpwhohas */ - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a - * conflict exists, a message is sent to the - * console. - */ - ((struct arpcom *)ifp)->ac_ipaddr = - IA_SIN(ifa)->sin_addr; - arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - /* - * XXX - This code is probably wrong - */ - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->arpcom.ac_enaddr); - else { - /* - * - */ - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)sc->arpcom.ac_enaddr, - sizeof(sc->arpcom.ac_enaddr)); - } - /* - * Set new address - */ - ed_init(ifp->if_unit); - break; - } -#endif - default: - ed_init(ifp->if_unit); - break; - } - break; - - case SIOCSIFFLAGS: - /* - * If interface is marked down and it is running, then stop it - */ - if (((ifp->if_flags & IFF_UP) == 0) && - (ifp->if_flags & IFF_RUNNING)) { - ed_stop(ifp->if_unit); - ifp->if_flags &= ~IFF_RUNNING; - } else { - /* - * If interface is marked up and it is stopped, then start it - */ - if ((ifp->if_flags & IFF_UP) && - ((ifp->if_flags & IFF_RUNNING) == 0)) - ed_init(ifp->if_unit); - } -#if NBPFILTER > 0 - if (ifp->if_flags & IFF_PROMISC) { - /* - * Set promiscuous mode on interface. - * XXX - for multicasts to work, we would need to - * write 1's in all bits of multicast - * hashing array. For now we assume that - * this was done in ed_init(). - */ - outb(sc->nic_addr + ED_P0_RCR, - ED_RCR_PRO|ED_RCR_AM|ED_RCR_AB); - } else { - /* - * XXX - for multicasts to work, we would need to - * rewrite the multicast hashing array with the - * proper hash (would have been destroyed above). - */ - outb(sc->nic_addr + ED_P0_RCR, ED_RCR_AB); - } -#endif - /* - * An unfortunate hack to provide the (required) software control - * of the tranceiver for 3Com boards. The LLC0 flag disables - * the tranceiver if set. - */ - if (sc->vendor == ED_VENDOR_3COM) { - if (ifp->if_flags & IFF_LLC0) { - outb(sc->asic_addr + ED_3COM_CR, 0); - } else { - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - } - } - - break; - - default: - error = EINVAL; - } - (void) splx(s); - return (error); -} - -/* - * Macro to calculate a new address within shared memory when given an offset - * from an address, taking into account ring-wrap. - */ -#define ringoffset(sc, start, off, type) \ - ((type)( ((caddr_t)(start)+(off) >= (sc)->smem_end) ? \ - (((caddr_t)(start)+(off))) - (sc)->smem_end \ - + (sc)->smem_ring: \ - ((caddr_t)(start)+(off)) )) - -/* - * Retreive packet from shared memory and send to the next level up via - * ether_input(). If there is a BPF listener, give a copy to BPF, too. - */ -ed_get_packet(sc, buf, len) - struct ed_softc *sc; - char *buf; - u_short len; -{ - struct ether_header *eh; - struct mbuf *m, *head, *ed_ring_to_mbuf(); - u_short off; - int resid; - u_short etype; - struct trailer_header { - u_short trail_type; - u_short trail_residual; - } trailer_header; - - /* Allocate a header mbuf */ - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - goto bad; - m->m_pkthdr.rcvif = &sc->arpcom.ac_if; - m->m_pkthdr.len = len; - m->m_len = 0; - head = m; - - eh = (struct ether_header *)buf; - - /* The following sillines is to make NFS happy */ -#define EROUND ((sizeof(struct ether_header) + 3) & ~3) -#define EOFF (EROUND - sizeof(struct ether_header)) - - /* - * The following assumes there is room for - * the ether header in the header mbuf - */ - head->m_data += EOFF; - bcopy(buf, mtod(head, caddr_t), sizeof(struct ether_header)); - buf += sizeof(struct ether_header); - head->m_len += sizeof(struct ether_header); - len -= sizeof(struct ether_header); - - etype = ntohs((u_short)eh->ether_type); - - /* - * Deal with trailer protocol: - * If trailer protocol, calculate the datasize as 'off', - * which is also the offset to the trailer header. - * Set resid to the amount of packet data following the - * trailer header. - * Finally, copy residual data into mbuf chain. - */ - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) { - - off = (etype - ETHERTYPE_TRAIL) << 9; - if ((off + sizeof(struct trailer_header)) > len) - goto bad; /* insanity */ - - eh->ether_type = *ringoffset(sc, buf, off, u_short *); - resid = ntohs(*ringoffset(sc, buf, off+2, u_short *)); - - if ((off + resid) > len) goto bad; /* insanity */ - - resid -= sizeof(struct trailer_header); - if (resid < 0) goto bad; /* insanity */ - - m = ed_ring_to_mbuf(sc, ringoffset(sc, buf, off+4, char *), head, resid); - if (m == 0) goto bad; - - len = off; - head->m_pkthdr.len -= 4; /* subtract trailer header */ - } - - /* - * Pull packet off interface. Or if this was a trailer packet, - * the data portion is appended. - */ - m = ed_ring_to_mbuf(sc, buf, m, len); - if (m == 0) goto bad; - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to bpf. - */ - if (sc->bpf) { - bpf_mtap(sc->bpf, head); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - * - * XXX This test does not support multicasts. - */ - if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) && - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) { - - m_freem(head); - return; - } - } -#endif - - /* - * Fix up data start offset in mbuf to point past ether header - */ - m_adj(head, sizeof(struct ether_header)); - - /* - * silly ether_input routine needs 'type' in host byte order - */ - eh->ether_type = ntohs(eh->ether_type); - - ether_input(&sc->arpcom.ac_if, eh, head); - return; - -bad: if (head) - m_freem(head); - return; -} - -/* - * Supporting routines - */ - -/* - * Given a source and destination address, copy 'amount' of a packet from - * the ring buffer into a linear destination buffer. Takes into account - * ring-wrap. - */ -static inline char * -ed_ring_copy(sc,src,dst,amount) - struct ed_softc *sc; - char *src; - char *dst; - u_short amount; -{ - u_short tmp_amount; - - /* does copy wrap to lower addr in ring buffer? */ - if (src + amount > sc->smem_end) { - tmp_amount = sc->smem_end - src; - bcopy(src,dst,tmp_amount); /* copy amount up to end of smem */ - amount -= tmp_amount; - src = sc->smem_ring; - dst += tmp_amount; - } - - bcopy(src, dst, amount); - - return(src + amount); -} - -/* - * Copy data from receive buffer to end of mbuf chain - * allocate additional mbufs as needed. return pointer - * to last mbuf in chain. - * sc = ed info (softc) - * src = pointer in ed ring buffer - * dst = pointer to last mbuf in mbuf chain to copy to - * amount = amount of data to copy - */ -struct mbuf * -ed_ring_to_mbuf(sc,src,dst,total_len) - struct ed_softc *sc; - char *src; - struct mbuf *dst; - u_short total_len; -{ - register struct mbuf *m = dst; - - while (total_len) { - register u_short amount = min(total_len, M_TRAILINGSPACE(m)); - - if (amount == 0) { /* no more data in this mbuf, alloc another */ - /* - * If there is enough data for an mbuf cluster, attempt - * to allocate one of those, otherwise, a regular - * mbuf will do. - * Note that a regular mbuf is always required, even if - * we get a cluster - getting a cluster does not - * allocate any mbufs, and one is needed to assign - * the cluster to. The mbuf that has a cluster - * extension can not be used to contain data - only - * the cluster can contain data. - */ - dst = m; - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); - - if (total_len >= MINCLSIZE) - MCLGET(m, M_DONTWAIT); - - m->m_len = 0; - dst->m_next = m; - amount = min(total_len, M_TRAILINGSPACE(m)); - } - - src = ed_ring_copy(sc, src, mtod(m, caddr_t) + m->m_len, amount); - - m->m_len += amount; - total_len -= amount; - - } - return (m); -} -#endif - diff --git a/sys/dev/ed/if_edreg.h b/sys/dev/ed/if_edreg.h deleted file mode 100644 index b9a76fa..0000000 --- a/sys/dev/ed/if_edreg.h +++ /dev/null @@ -1,840 +0,0 @@ -/* - * National Semiconductor DS8390 NIC register definitions - * - * $Log: if_edreg.h,v $ - * Revision 1.3 93/07/20 15:25:25 davidg - * added config flags for forcing 8/16bit mode and disabling double - * xmit buffers. - * - * Revision 1.2 93/06/23 03:03:05 davidg - * added some additional definitions for the 83C584 bus interface - * chip (SMC/WD boards) - * - * Revision 1.1 93/06/23 03:01:07 davidg - * Initial revision - * - */ - -/* - * Page 0 register offsets - */ -#define ED_P0_CR 0x00 /* Command Register */ - -#define ED_P0_CLDA0 0x01 /* Current Local DMA Addr low (read) */ -#define ED_P0_PSTART 0x01 /* Page Start register (write) */ - -#define ED_P0_CLDA1 0x02 /* Current Local DMA Addr high (read) */ -#define ED_P0_PSTOP 0x02 /* Page Stop register (write) */ - -#define ED_P0_BNRY 0x03 /* Boundary Pointer */ - -#define ED_P0_TSR 0x04 /* Transmit Status Register (read) */ -#define ED_P0_TPSR 0x04 /* Transmit Page Start (write) */ - -#define ED_P0_NCR 0x05 /* Number of Collisions Reg (read) */ -#define ED_P0_TBCR0 0x05 /* Transmit Byte count, low (write) */ - -#define ED_P0_FIFO 0x06 /* FIFO register (read) */ -#define ED_P0_TBCR1 0x06 /* Transmit Byte count, high (write) */ - -#define ED_P0_ISR 0x07 /* Interrupt Status Register */ - -#define ED_P0_CRDA0 0x08 /* Current Remote DMA Addr low (read) */ -#define ED_P0_RSAR0 0x08 /* Remote Start Address low (write) */ - -#define ED_P0_CRDA1 0x09 /* Current Remote DMA Addr high (read) */ -#define ED_P0_RSAR1 0x09 /* Remote Start Address high (write) */ - -#define ED_P0_RBCR0 0x0a /* Remote Byte Count low (write) */ - -#define ED_P0_RBCR1 0x0b /* Remote Byte Count high (write) */ - -#define ED_P0_RSR 0x0c /* Receive Status (read) */ -#define ED_P0_RCR 0x0c /* Receive Configuration Reg (write) */ - -#define ED_P0_CNTR0 0x0d /* frame alignment error counter (read) */ -#define ED_P0_TCR 0x0d /* Transmit Configuration Reg (write) */ - -#define ED_P0_CNTR1 0x0e /* CRC error counter (read) */ -#define ED_P0_DCR 0x0e /* Data Configuration Reg (write) */ - -#define ED_P0_CNTR2 0x0f /* missed packet counter (read) */ -#define ED_P0_IMR 0x0f /* Interrupt Mask Register (write) */ - -/* - * Page 1 register offsets - */ -#define ED_P1_CR 0x00 /* Command Register */ -#define ED_P1_PAR0 0x01 /* Physical Address Register 0 */ -#define ED_P1_PAR1 0x02 /* Physical Address Register 1 */ -#define ED_P1_PAR2 0x03 /* Physical Address Register 2 */ -#define ED_P1_PAR3 0x04 /* Physical Address Register 3 */ -#define ED_P1_PAR4 0x05 /* Physical Address Register 4 */ -#define ED_P1_PAR5 0x06 /* Physical Address Register 5 */ -#define ED_P1_CURR 0x07 /* Current RX ring-buffer page */ -#define ED_P1_MAR0 0x08 /* Multicast Address Register 0 */ -#define ED_P1_MAR1 0x09 /* Multicast Address Register 1 */ -#define ED_P1_MAR2 0x0a /* Multicast Address Register 2 */ -#define ED_P1_MAR3 0x0b /* Multicast Address Register 3 */ -#define ED_P1_MAR4 0x0c /* Multicast Address Register 4 */ -#define ED_P1_MAR5 0x0d /* Multicast Address Register 5 */ -#define ED_P1_MAR6 0x0e /* Multicast Address Register 6 */ -#define ED_P1_MAR7 0x0f /* Multicast Address Register 7 */ - -/* - * Page 2 register offsets - */ -#define ED_P2_CR 0x00 /* Command Register */ -#define ED_P2_PSTART 0x01 /* Page Start (read) */ -#define ED_P2_CLDA0 0x01 /* Current Local DMA Addr 0 (write) */ -#define ED_P2_PSTOP 0x02 /* Page Stop (read) */ -#define ED_P2_CLDA1 0x02 /* Current Local DMA Addr 1 (write) */ -#define ED_P2_RNPP 0x03 /* Remote Next Packet Pointer */ -#define ED_P2_TPSR 0x04 /* Transmit Page Start (read) */ -#define ED_P2_LNPP 0x05 /* Local Next Packet Pointer */ -#define ED_P2_ACU 0x06 /* Address Counter Upper */ -#define ED_P2_ACL 0x07 /* Address Counter Lower */ -#define ED_P2_RCR 0x0c /* Receive Configuration Register (read) */ -#define ED_P2_TCR 0x0d /* Transmit Configuration Register (read) */ -#define ED_P2_DCR 0x0e /* Data Configuration Register (read) */ -#define ED_P2_IMR 0x0f /* Interrupt Mask Register (read) */ - -/* - * Command Register (CR) definitions - */ - -/* - * STP: SToP. Software reset command. Takes the controller offline. No - * packets will be received or transmitted. Any reception or - * transmission in progress will continue to completion before - * entering reset state. To exit this state, the STP bit must - * reset and the STA bit must be set. The software reset has - * executed only when indicated by the RST bit in the ISR being - * set. - */ -#define ED_CR_STP 0x01 - -/* - * STA: STArt. This bit is used to activate the NIC after either power-up, - * or when the NIC has been put in reset mode by software command - * or error. - */ -#define ED_CR_STA 0x02 - -/* - * TXP: Transmit Packet. This bit must be set to indicate transmission of - * a packet. TXP is internally reset either after the transmission is - * completed or aborted. This bit should be set only after the Transmit - * Byte Count and Transmit Page Start register have been programmed. - */ -#define ED_CR_TXP 0x04 - -/* - * RD0, RD1, RD2: Remote DMA Command. These three bits control the operation - * of the remote DMA channel. RD2 can be set to abort any remote DMA - * command in progress. The Remote Byte Count registers should be cleared - * when a remote DMA has been aborted. The Remote Start Addresses are not - * restored to the starting address if the remote DMA is aborted. - * - * RD2 RD1 RD0 function - * 0 0 0 not allowed - * 0 0 1 remote read - * 0 1 0 remote write - * 0 1 1 send packet - * 1 X X abort - */ -#define ED_CR_RD0 0x08 -#define ED_CR_RD1 0x10 -#define ED_CR_RD2 0x20 - -/* - * PS0, PS1: Page Select. The two bits select which register set or 'page' to - * access. - * - * PS1 PS0 page - * 0 0 0 - * 0 1 1 - * 1 0 2 - * 1 1 reserved - */ -#define ED_CR_PS0 0x40 -#define ED_CR_PS1 0x80 -/* bit encoded aliases */ -#define ED_CR_PAGE_0 0x00 /* (for consistency) */ -#define ED_CR_PAGE_1 0x40 -#define ED_CR_PAGE_2 0x80 - -/* - * Interrupt Status Register (ISR) definitions - */ - -/* - * PRX: Packet Received. Indicates packet received with no errors. - */ -#define ED_ISR_PRX 0x01 - -/* - * PTX: Packet Transmitted. Indicates packet transmitted with no errors. - */ -#define ED_ISR_PTX 0x02 - -/* - * RXE: Receive Error. Indicates that a packet was received with one or more - * the following errors: CRC error, frame alignment error, FIFO overrun, - * missed packet. - */ -#define ED_ISR_RXE 0x04 - -/* - * TXE: Transmission Error. Indicates that an attempt to transmit a packet - * resulted in one or more of the following errors: excessive - * collisions, FIFO underrun. - */ -#define ED_ISR_TXE 0x08 - -/* - * OVW: OverWrite. Indicates a receive ring-buffer overrun. Incoming network - * would exceed (has exceeded?) the boundry pointer, resulting in data - * that was previously received and not yet read from the buffer to be - * overwritten. - */ -#define ED_ISR_OVW 0x10 - -/* - * CNT: Counter Overflow. Set when the MSB of one or more of the Network Talley - * Counters has been set. - */ -#define ED_ISR_CNT 0x20 - -/* - * RDC: Remote Data Complete. Indicates that a Remote DMA operation has completed. - */ -#define ED_ISR_RDC 0x40 - -/* - * RST: Reset status. Set when the NIC enters the reset state and cleared when a - * Start Command is issued to the CR. This bit is also set when a receive - * ring-buffer overrun (OverWrite) occurs and is cleared when one or more - * packets have been removed from the ring. This is a read-only bit. - */ -#define ED_ISR_RST 0x80 - -/* - * Interrupt Mask Register (IMR) definitions - */ - -/* - * PRXE: Packet Received interrupt Enable. If set, a received packet will cause - * an interrupt. - */ -#define ED_IMR_PRXE 0x01 - -/* - * PTXE: Packet Transmit interrupt Enable. If set, an interrupt is generated when - * a packet transmission completes. - */ -#define ED_IMR_PTXE 0x02 - -/* - * RXEE: Receive Error interrupt Enable. If set, an interrupt will occur whenever a - * packet is received with an error. - */ -#define ED_IMR_RXEE 0x04 - -/* - * TXEE: Transmit Error interrupt Enable. If set, an interrupt will occur whenever - * a transmission results in an error. - */ -#define ED_IMR_TXEE 0x08 - -/* - * OVWE: OverWrite error interrupt Enable. If set, an interrupt is generated whenever - * the receive ring-buffer is overrun. i.e. when the boundry pointer is exceeded. - */ -#define ED_IMR_OVWE 0x10 - -/* - * CNTE: Counter overflow interrupt Enable. If set, an interrupt is generated whenever - * the MSB of one or more of the Network Statistics counters has been set. - */ -#define ED_IMR_CNTE 0x20 - -/* - * RDCE: Remote DMA Complete interrupt Enable. If set, an interrupt is generated - * when a remote DMA transfer has completed. - */ -#define ED_IMR_RDCE 0x40 - -/* - * bit 7 is unused/reserved - */ - -/* - * Data Configuration Register (DCR) definitions - */ - -/* - * WTS: Word Transfer Select. WTS establishes byte or word transfers for - * both remote and local DMA transfers - */ -#define ED_DCR_WTS 0x01 - -/* - * BOS: Byte Order Select. BOS sets the byte order for the host. - * Should be 0 for 80x86, and 1 for 68000 series processors - */ -#define ED_DCR_BOS 0x02 - -/* - * LAS: Long Address Select. When LAS is 1, the contents of the remote - * DMA registers RSAR0 and RSAR1 are used to provide A16-A31 - */ -#define ED_DCR_LAS 0x04 - -/* - * LS: Loopback Select. When 0, loopback mode is selected. Bits D1 and D2 - * of the TCR must also be programmed for loopback operation. - * When 1, normal operation is selected. - */ -#define ED_DCR_LS 0x08 - -/* - * AR: Auto-initialize Remote. When 0, data must be removed from ring-buffer - * under program control. When 1, remote DMA is automatically initiated - * and the boundry pointer is automatically updated - */ -#define ED_DCR_AR 0x10 - -/* - * FT0, FT1: Fifo Threshold select. - * FT1 FT0 Word-width Byte-width - * 0 0 1 word 2 bytes - * 0 1 2 words 4 bytes - * 1 0 4 words 8 bytes - * 1 1 8 words 12 bytes - * - * During transmission, the FIFO threshold indicates the number of bytes - * or words that the FIFO has filled from the local DMA before BREQ is - * asserted. The transmission threshold is 16 bytes minus the receiver - * threshold. - */ -#define ED_DCR_FT0 0x20 -#define ED_DCR_FT1 0x40 - -/* - * bit 7 (0x80) is unused/reserved - */ - -/* - * Transmit Configuration Register (TCR) definitions - */ - -/* - * CRC: Inhibit CRC. If 0, CRC will be appended by the transmitter, if 0, CRC - * is not appended by the transmitter. - */ -#define ED_TCR_CRC 0x01 - -/* - * LB0, LB1: Loopback control. These two bits set the type of loopback that is - * to be performed. - * - * LB1 LB0 mode - * 0 0 0 - normal operation (DCR_LS = 0) - * 0 1 1 - internal loopback (DCR_LS = 0) - * 1 0 2 - external loopback (DCR_LS = 1) - * 1 1 3 - external loopback (DCR_LS = 0) - */ -#define ED_TCR_LB0 0x02 -#define ED_TCR_LB1 0x04 - -/* - * ATD: Auto Transmit Disable. Clear for normal operation. When set, allows - * another station to disable the NIC's transmitter by transmitting to - * a multicast address hashing to bit 62. Reception of a multicast address - * hashing to bit 63 enables the transmitter. - */ -#define ED_TCR_ATD 0x08 - -/* - * OFST: Collision Offset enable. This bit when set modifies the backoff - * algorithm to allow prioritization of nodes. - */ -#define ED_TCR_OFST 0x10 - -/* - * bits 5, 6, and 7 are unused/reserved - */ - -/* - * Transmit Status Register (TSR) definitions - */ - -/* - * PTX: Packet Transmitted. Indicates successful transmission of packet. - */ -#define ED_TSR_PTX 0x01 - -/* - * bit 1 (0x02) is unused/reserved - */ - -/* - * COL: Transmit Collided. Indicates that the transmission collided at least - * once with another station on the network. - */ -#define ED_TSR_COL 0x04 - -/* - * ABT: Transmit aborted. Indicates that the transmission was aborted due to - * excessive collisions. - */ -#define ED_TSR_ABT 0x08 - -/* - * CRS: Carrier Sense Lost. Indicates that carrier was lost during the - * transmission of the packet. (Transmission is not aborted because - * of a loss of carrier) - */ -#define ED_TSR_CRS 0x10 - -/* - * FU: FIFO Underrun. Indicates that the NIC wasn't able to access bus/ - * transmission memory before the FIFO emptied. Transmission of the - * packet was aborted. - */ -#define ED_TSR_FU 0x20 - -/* - * CDH: CD Heartbeat. Indicates that the collision detection circuitry - * isn't working correctly during a collision heartbeat test. - */ -#define ED_TSR_CDH 0x40 - -/* - * OWC: Out of Window Collision: Indicates that a collision occurred after - * a slot time (51.2us). The transmission is rescheduled just as in - * normal collisions. - */ -#define ED_TSR_OWC 0x80 - -/* - * Receiver Configuration Register (RCR) definitions - */ - -/* - * SEP: Save Errored Packets. If 0, error packets are discarded. If set to 1, - * packets with CRC and frame errors are not discarded. - */ -#define ED_RCR_SEP 0x01 - -/* - * AR: Accept Runt packet. If 0, packet with less than 64 byte are discarded. - * If set to 1, packets with less than 64 byte are not discarded. - */ -#define ED_RCR_AR 0x02 - -/* - * AB: Accept Broadcast. If set, packets sent to the broadcast address will be - * accepted. - */ -#define ED_RCR_AB 0x04 - -/* - * AM: Accept Multicast. If set, packets sent to a multicast address are checked - * for a match in the hashing array. If clear, multicast packets are ignored. - */ -#define ED_RCR_AM 0x08 - -/* - * PRO: Promiscuous Physical. If set, all packets with a physical addresses are - * accepted. If clear, a physical destination address must match this - * station's address. Note: for full promiscuous mode, RCR_AB and RCR_AM - * must also be set. In addition, the multicast hashing array must be set - * to all 1's so that all multicast addresses are accepted. - */ -#define ED_RCR_PRO 0x10 - -/* - * MON: Monitor Mode. If set, packets will be checked for good CRC and framing, - * but are not stored in the ring-buffer. If clear, packets are stored (normal - * operation). - */ -#define ED_RCR_MON 0x20 - -/* - * bits 6 and 7 are unused/reserved. - */ - -/* - * Receiver Status Register (RSR) definitions - */ - -/* - * PRX: Packet Received without error. - */ -#define ED_RSR_PRX 0x01 - -/* - * CRC: CRC error. Indicates that a packet has a CRC error. Also set for frame - * alignment errors. - */ -#define ED_RSR_CRC 0x02 - -/* - * FAE: Frame Alignment Error. Indicates that the incoming packet did not end on - * a byte boundry and the CRC did not match at the last byte boundry. - */ -#define ED_RSR_FAE 0x04 - -/* - * FO: FIFO Overrun. Indicates that the FIFO was not serviced (during local DMA) - * causing it to overrun. Reception of the packet is aborted. - */ -#define ED_RSR_FO 0x08 - -/* - * MPA: Missed Packet. Indicates that the received packet couldn't be stored in - * the ring-buffer because of insufficient buffer space (exceeding the - * boundry pointer), or because the transfer to the ring-buffer was inhibited - * by RCR_MON - monitor mode. - */ -#define ED_RSR_MPA 0x10 - -/* - * PHY: Physical address. If 0, the packet received was sent to a physical address. - * If 1, the packet was accepted because of a multicast/broadcast address - * match. - */ -#define ED_RSR_PHY 0x20 - -/* - * DIS: Receiver Disabled. Set to indicate that the receiver has enetered monitor - * mode. Cleared when the receiver exits monitor mode. - */ -#define ED_RSR_DIS 0x40 - -/* - * DFR: Deferring. Set to indicate a 'jabber' condition. The CRS and COL inputs - * are active, and the transceiver has set the CD line as a result of the - * jabber. - */ -#define ED_RSR_DFR 0x80 - -/* - * receive ring discriptor - * - * The National Semiconductor DS8390 Network interface controller uses - * the following receive ring headers. The way this works is that the - * memory on the interface card is chopped up into 256 bytes blocks. - * A contiguous portion of those blocks are marked for receive packets - * by setting start and end block #'s in the NIC. For each packet that - * is put into the receive ring, one of these headers (4 bytes each) is - * tacked onto the front. - */ -struct ed_ring { - struct edr_status { /* received packet status */ - u_char rs_prx:1, /* packet received intack */ - rs_crc:1, /* crc error */ - rs_fae:1, /* frame alignment error */ - rs_fo:1, /* fifo overrun */ - rs_mpa:1, /* packet received intack */ - rs_phy:1, /* packet received intack */ - rs_dis:1, /* packet received intack */ - rs_dfr:1; /* packet received intack */ - } ed_rcv_status; /* received packet status */ - u_char next_packet; /* pointer to next packet */ - u_short count; /* bytes in packet (length + 4) */ -}; - -/* - * Common constants - */ -#define ED_PAGE_SIZE 256 /* Size of RAM pages in bytes */ -#define ED_TXBUF_SIZE 6 /* Size of TX buffer in pages */ - -/* - * Vendor types - */ -#define ED_VENDOR_WD_SMC 0x00 /* Western Digital/SMC */ -#define ED_VENDOR_3COM 0x01 /* 3Com */ - -/* - * Compile-time config flags - */ -/* - * this sets the default for enabling/disablng the tranceiver - */ -#define ED_FLAGS_DISABLE_TRANCEIVER 0x01 - -/* - * This forces the board to be used in 8/16bit mode even if it - * autoconfigs differently - */ -#define ED_FLAGS_FORCE_8BIT_MODE 0x02 -#define ED_FLAGS_FORCE_16BIT_MODE 0x04 - -/* - * This disables the use of double transmit buffers. - */ -#define ED_FLAGS_NO_DOUBLE_BUFFERING 0x08 - -/* - * Definitions for Western digital/SMC WD80x3 series ASIC - */ -/* - * Memory Select Register (MSR) - */ -#define ED_WD_MSR 0 - -#define ED_WD_MSR_ADDR 0x3f /* Memory decode bits 18-13 */ -#define ED_WD_MSR_MENB 0x40 /* Memory enable */ -#define ED_WD_MSR_RST 0x80 /* Reset board */ - -/* - * Interface Configuration Register (ICR) - */ -#define ED_WD_ICR 1 - -#define ED_WD_ICR_16BIT 0x01 /* 16-bit interface */ -#define ED_WD_ICR_OAR 0x02 /* select register. 0=BIO 1=EAR */ -#define ED_WD_ICR_IR2 0x04 /* high order bit of encoded IRQ */ -#define ED_WD_ICR_MSZ 0x08 /* memory size (0=8k 1=32k) */ -#define ED_WD_ICR_RLA 0x10 /* recall LAN address */ -#define ED_WD_ICR_RX7 0x20 /* recall all but i/o and LAN address */ -#define ED_WD_ICR_RIO 0x40 /* recall i/o address */ -#define ED_WD_ICR_STO 0x80 /* store to non-volatile memory */ - -/* - * IO Address Register (IAR) - */ -#define ED_WD_IAR 2 - -/* - * EEROM Address Register - */ -#define ED_WD_EAR 3 - -/* - * Interrupt Request Register (IRR) - */ -#define ED_WD_IRR 4 - -#define ED_WD_IRR_0WS 0x01 /* use 0 wait-states on 8 bit bus */ -#define ED_WD_IRR_OUT1 0x02 /* WD83C584 pin 1 output */ -#define ED_WD_IRR_OUT2 0x04 /* WD83C584 pin 2 output */ -#define ED_WD_IRR_OUT3 0x08 /* WD83C584 pin 3 output */ -#define ED_WD_IRR_FLASH 0x10 /* Flash RAM is in the ROM socket */ - -/* - * The three bit of the encoded IRQ are decoded as follows: - * - * IR2 IR1 IR0 IRQ - * 0 0 0 2/9 - * 0 0 1 3 - * 0 1 0 5 - * 0 1 1 7 - * 1 0 0 10 - * 1 0 1 11 - * 1 1 0 15 - * 1 1 1 4 - */ -#define ED_WD_IRR_IR0 0x20 /* bit 0 of encoded IRQ */ -#define ED_WD_IRR_IR1 0x40 /* bit 1 of encoded IRQ */ -#define ED_WD_IRR_IEN 0x80 /* Interrupt enable */ - -/* - * LA Address Register (LAAR) - */ -#define ED_WD_LAAR 5 - -#define ED_WD_LAAR_ADDRHI 0x1f /* bits 23-19 of RAM address */ -#define ED_WD_LAAR_0WS16 0x20 /* enable 0 wait-states on 16 bit bus */ -#define ED_WD_LAAR_L16EN 0x40 /* enable 16-bit operation */ -#define ED_WD_LAAR_M16EN 0x80 /* enable 16-bit memory access */ - -/* i/o base offset to station address/card-ID PROM */ -#define ED_WD_PROM 8 - -/* i/o base offset to CARD ID */ -#define ED_WD_CARD_ID ED_WD_PROM+6 - -#define ED_TYPE_WD8003S 0x02 -#define ED_TYPE_WD8003E 0x03 -#define ED_TYPE_WD8013EBT 0x05 -#define ED_TYPE_WD8013EB 0x27 -#define ED_TYPE_WD8013EBP 0x2c -#define ED_TYPE_WD8013EPC 0x29 - -/* Bit definitions in card ID */ -#define ED_WD_REV_MASK 0x1f /* Revision mask */ -#define ED_WD_SOFTCONFIG 0x20 /* Soft config */ -#define ED_WD_LARGERAM 0x40 /* Large RAM */ -#define ED_MICROCHANEL 0x80 /* Microchannel bus (vs. isa) */ - -/* - * Checksum total. All 8 bytes in station address PROM will add up to this - */ -#define ED_WD_ROM_CHECKSUM_TOTAL 0xFF - -#define ED_WD_NIC_OFFSET 0x10 /* I/O base offset to NIC */ -#define ED_WD_ASIC_OFFSET 0 /* I/O base offset to ASIC */ -#define ED_WD_IO_PORTS 32 /* # of i/o addresses used */ - -#define ED_WD_PAGE_OFFSET 0 /* page offset for NIC access to mem */ - -/* - * Definitions for 3Com 3c503 - */ -#define ED_3COM_NIC_OFFSET 0 -#define ED_3COM_ASIC_OFFSET 0x400 /* offset to nic i/o regs */ - -/* - * XXX - The I/O address range is fragmented in the 3c503; this is the - * number of regs at iobase. - */ -#define ED_3COM_IO_PORTS 16 /* # of i/o addresses used */ - -#define ED_3COM_PAGE_OFFSET 0x20 /* memory starts in second bank */ - -/* - * Page Start Register. Must match PSTART in NIC - */ -#define ED_3COM_PSTR 0 - -/* - * Page Stop Register. Must match PSTOP in NIC - */ -#define ED_3COM_PSPR 1 - -/* - * Drq Timer Register. Determines number of bytes to be transfered during - * a DMA burst. - */ -#define ED_3COM_DQTR 2 - -/* - * Base Configuration Register. Read-only register which contains the - * board-configured I/O base address of the adapter. Bit encoded. - */ -#define ED_3COM_BCFR 3 - -#define ED_3COM_BCFR_2E0 0x01 -#define ED_3COM_BCFR_2A0 0x02 -#define ED_3COM_BCFR_280 0x04 -#define ED_3COM_BCFR_250 0x08 -#define ED_3COM_BCFR_350 0x10 -#define ED_3COM_BCFR_330 0x20 -#define ED_3COM_BCFR_310 0x40 -#define ED_3COM_BCFR_300 0x80 - -/* - * EPROM Configuration Register. Read-only register which contains the - * board-configured memory base address. Bit encoded. - */ -#define ED_3COM_PCFR 4 - -#define ED_3COM_PCFR_C8000 0x10 -#define ED_3COM_PCFR_CC000 0x20 -#define ED_3COM_PCFR_D8000 0x40 -#define ED_3COM_PCFR_DC000 0x80 - -/* - * GA Configuration Register. Gate-Array Configuration Register. - */ -#define ED_3COM_GACFR 5 - -/* - * mbs2 mbs1 mbs0 start address - * 0 0 0 0x0000 - * 0 0 1 0x2000 - * 0 1 0 0x4000 - * 0 1 1 0x6000 - * - * Note that with adapters with only 8K, the setting for 0x2000 must - * always be used. - */ -#define ED_3COM_GACFR_MBS0 0x01 -#define ED_3COM_GACFR_MBS1 0x02 -#define ED_3COM_GACFR_MBS2 0x04 - -#define ED_3COM_GACFR_RSEL 0x08 /* enable shared memory */ -#define ED_3COM_GACFR_TEST 0x10 /* for GA testing */ -#define ED_3COM_GACFR_OWS 0x20 /* select 0WS access to GA */ -#define ED_3COM_GACFR_TCM 0x40 /* Mask DMA interrupts */ -#define ED_3COM_GACFR_NIM 0x80 /* Mask NIC interrupts */ - -/* - * Control Register. Miscellaneous control functions. - */ -#define ED_3COM_CR 6 - -#define ED_3COM_CR_RST 0x01 /* Reset GA and NIC */ -#define ED_3COM_CR_XSEL 0x02 /* Transceiver select. BNC=1(def) AUI=0 */ -#define ED_3COM_CR_EALO 0x04 /* window EA PROM 0-15 to I/O base */ -#define ED_3COM_CR_EAHI 0x08 /* window EA PROM 16-31 to I/O base */ -#define ED_3COM_CR_SHARE 0x10 /* select interrupt sharing option */ -#define ED_3COM_CR_DBSEL 0x20 /* Double buffer select */ -#define ED_3COM_CR_DDIR 0x40 /* DMA direction select */ -#define ED_3COM_CR_START 0x80 /* Start DMA controller */ - -/* - * Status Register. Miscellaneous status information. - */ -#define ED_3COM_STREG 7 - -#define ED_3COM_STREG_REV 0x07 /* GA revision */ -#define ED_3COM_STREG_DIP 0x08 /* DMA in progress */ -#define ED_3COM_STREG_DTC 0x10 /* DMA terminal count */ -#define ED_3COM_STREG_OFLW 0x20 /* Overflow */ -#define ED_3COM_STREG_UFLW 0x40 /* Underflow */ -#define ED_3COM_STREG_DPRDY 0x80 /* Data port ready */ - -/* - * Interrupt/DMA Configuration Register - */ -#define ED_3COM_IDCFR 8 - -#define ED_3COM_IDCFR_DRQ0 0x01 /* DMA request 1 select */ -#define ED_3COM_IDCFR_DRQ1 0x02 /* DMA request 2 select */ -#define ED_3COM_IDCFR_DRQ2 0x04 /* DMA request 3 select */ -#define ED_3COM_IDCFR_UNUSED 0x08 /* not used */ -#define ED_3COM_IDCFR_IRQ2 0x10 /* Interrupt request 2 select */ -#define ED_3COM_IDCFR_IRQ3 0x20 /* Interrupt request 3 select */ -#define ED_3COM_IDCFR_IRQ4 0x40 /* Interrupt request 4 select */ -#define ED_3COM_IDCFR_IRQ5 0x80 /* Interrupt request 5 select */ - -/* - * DMA Address Register MSB - */ -#define ED_3COM_DAMSB 9 - -/* - * DMA Address Register LSB - */ -#define ED_3COM_DALSB 0x0a - -/* - * Vector Pointer Register 2 - */ -#define ED_3COM_VPTR2 0x0b - -/* - * Vector Pointer Register 1 - */ -#define ED_3COM_VPTR1 0x0c - -/* - * Vector Pointer Register 0 - */ -#define ED_3COM_VPTR0 0x0d - -/* - * Register File Access MSB - */ -#define ED_3COM_RFMSB 0x0e - -/* - * Register File Access LSB - */ -#define ED_3COM_RFLSB 0x0f diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c deleted file mode 100644 index ca92b16..0000000 --- a/sys/dev/fdc/fdc.c +++ /dev/null @@ -1,899 +0,0 @@ -/*#define DEBUG 1*/ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Don Ahn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)fd.c 7.4 (Berkeley) 5/25/91 - * - * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE - * -------------------- ----- ---------------------- - * CURRENT PATCH LEVEL: 1 00153 - * -------------------- ----- ---------------------- - * - * 20 Apr 93 Julian Elischer Heavily re worked, see notes below - * - * Largely rewritten to handle multiple controllers and drives - * By Julian Elischer, Sun Apr 4 16:34:33 WST 1993 - */ -char rev[] = "$Revision: 1.1.1.1 $"; -/* - * $Header: /a/cvs/386BSD/src/sys.386bsd/i386/isa/fd.c,v 1.1.1.1 1993/06/12 14:58:02 rgrimes Exp $ - */ -/* - * $Log: fd.c,v $ - * Revision 1.1.1.1 1993/06/12 14:58:02 rgrimes - * Initial import, 0.1 + pk 0.2.4-B1 - * - * Revision 1.10 93/04/13 16:53:29 root - * make sure turning off a drive motor doesn't deselect another - * drive active at the time. - * Also added a pointer from the fd_data to it's fd_type. - * - * Revision 1.9 93/04/13 15:31:02 root - * make all seeks go through DOSEEK state so are sure of being done right. - * - * Revision 1.8 93/04/12 21:20:13 root - * only check if old fd is the one we are working on if there IS - * an old fd pointer. (in fdstate()) - * - * Revision 1.7 93/04/11 17:05:35 root - * cleanup timeouts etc. - * also fix bug to select teh correct drive when running > 1 drive - * at a time. - * - * Revision 1.6 93/04/05 00:48:45 root - * change a timeout and add version to banner message - * - * Revision 1.5 93/04/04 16:39:08 root - * first working version.. some floppy controllers don't seem to - * like 2 int. status inquiries in a row. - * - */ - -#include "fd.h" -#if NFD > 0 - -#include "param.h" -#include "dkbad.h" -#include "systm.h" -#include "conf.h" -#include "file.h" -#include "ioctl.h" -#include "buf.h" -#include "uio.h" -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/fdreg.h" -#include "i386/isa/icu.h" -#include "i386/isa/rtc.h" -#undef NFD -#define NFD 2 - -#define FDUNIT(s) ((s>>3)&1) -#define FDTYPE(s) ((s)&7) - -#define b_cylin b_resid -#define FDBLK 512 -#define NUMTYPES 4 - -struct fd_type { - int sectrac; /* sectors per track */ - int secsize; /* size code for sectors */ - int datalen; /* data len when secsize = 0 */ - int gap; /* gap len between sectors */ - int tracks; /* total num of tracks */ - int size; /* size of disk in sectors */ - int steptrac; /* steps per cylinder */ - int trans; /* transfer speed code */ - int heads; /* number of heads */ -}; - -struct fd_type fd_types[NUMTYPES] = -{ - { 18,2,0xFF,0x1B,80,2880,1,0,2 }, /* 1.44 meg HD 3.5in floppy */ - { 15,2,0xFF,0x1B,80,2400,1,0,2 }, /* 1.2 meg HD floppy */ - { 9,2,0xFF,0x23,40,720,2,1,2 }, /* 360k floppy in 1.2meg drive */ - { 9,2,0xFF,0x2A,40,720,1,1,2 }, /* 360k floppy in DD drive */ -}; - -#define DRVS_PER_CTLR 2 -/***********************************************************************\ -* Per controller structure. * -\***********************************************************************/ -struct fdc_data -{ - int fdcu; /* our unit number */ - int baseport; - int dmachan; - int flags; -#define FDC_ATTACHED 0x01 - struct fd_data *fd; - int fdu; /* the active drive */ - struct buf head; /* Head of buf chain */ - struct buf rhead; /* Raw head of buf chain */ - int state; - int retry; - int status[7]; /* copy of the registers */ -}fdc_data[(NFD+1)/DRVS_PER_CTLR]; - -/***********************************************************************\ -* Per drive structure. * -* N per controller (presently 2) (DRVS_PER_CTLR) * -\***********************************************************************/ -struct fd_data { - struct fdc_data *fdc; - int fdu; /* this unit number */ - int fdsu; /* this units number on this controller */ - int type; /* Drive type (HD, DD */ - struct fd_type *ft; /* pointer to the type descriptor */ - int flags; -#define FD_OPEN 0x01 /* it's open */ -#define FD_ACTIVE 0x02 /* it's active */ -#define FD_MOTOR 0x04 /* motor should be on */ -#define FD_MOTOR_WAIT 0x08 /* motor coming up */ - int skip; - int hddrv; - int track; /* where we think the head is */ -} fd_data[NFD]; - -/***********************************************************************\ -* Throughout this file the following conventions will be used: * -* fd is a pointer to the fd_data struct for the drive in question * -* fdc is a pointer to the fdc_data struct for the controller * -* fdu is the floppy drive unit number * -* fdcu is the floppy controller unit number * -* fdsu is the floppy drive unit number on that controller. (sub-unit) * -\***********************************************************************/ -typedef int fdu_t; -typedef int fdcu_t; -typedef int fdsu_t; -typedef struct fd_data *fd_p; -typedef struct fdc_data *fdc_p; - -#define DEVIDLE 0 -#define FINDWORK 1 -#define DOSEEK 2 -#define SEEKCOMPLETE 3 -#define IOCOMPLETE 4 -#define RECALCOMPLETE 5 -#define STARTRECAL 6 -#define RESETCTLR 7 -#define SEEKWAIT 8 -#define RECALWAIT 9 -#define MOTORWAIT 10 -#define IOTIMEDOUT 11 - -#ifdef DEBUG -char *fdstates[] = -{ -"DEVIDLE", -"FINDWORK", -"DOSEEK", -"SEEKCOMPLETE", -"IOCOMPLETE", -"RECALCOMPLETE", -"STARTRECAL", -"RESETCTLR", -"SEEKWAIT", -"RECALWAIT", -"MOTORWAIT", -"IOTIMEDOUT" -}; - - -int fd_debug = 1; -#define TRACE0(arg) if(fd_debug) printf(arg) -#define TRACE1(arg1,arg2) if(fd_debug) printf(arg1,arg2) -#else DEBUG -#define TRACE0(arg) -#define TRACE1(arg1,arg2) -#endif DEBUG - -extern int hz; -/* state needed for current transfer */ - -/****************************************************************************/ -/* autoconfiguration stuff */ -/****************************************************************************/ -int fdprobe(), fdattach(), fd_turnoff(); - -struct isa_driver fddriver = { - fdprobe, fdattach, "fd", -}; - -/* - * probe for existance of controller - */ -fdprobe(dev) -struct isa_device *dev; -{ - fdcu_t fdcu = dev->id_unit; - if(fdc_data[fdcu].flags & FDC_ATTACHED) - { - printf("fdc: same unit (%d) used multiple times\n",fdcu); - return 0; - } - - fdc_data[fdcu].baseport = dev->id_iobase; - - /* see if it can handle a command */ - if (out_fdc(fdcu,NE7CMD_SPECIFY) < 0) - { - return(0); - } - out_fdc(fdcu,0xDF); - out_fdc(fdcu,2); - return (IO_FDCSIZE); -} - -/* - * wire controller into system, look for floppy units - */ -fdattach(dev) -struct isa_device *dev; -{ - unsigned fdt,st0, cyl; - int hdr; - fdu_t fdu; - fdcu_t fdcu = dev->id_unit; - fdc_p fdc = fdc_data + fdcu; - fd_p fd; - int fdsu; - - fdc->fdcu = fdcu; - fdc->flags |= FDC_ATTACHED; - fdc->dmachan = dev->id_drq; - fdc->state = DEVIDLE; - - fdt = rtcin(RTC_FDISKETTE); - hdr = 0; - - /* check for each floppy drive */ - for (fdu = (fdcu * DRVS_PER_CTLR),fdsu = 0; - ((fdu < NFD) && (fdsu < DRVS_PER_CTLR)); - fdu++,fdsu++) - { - /* is there a unit? */ - if ((fdt & 0xf0) == RTCFDT_NONE) - continue; - -#ifdef notyet - /* select it */ - fd_turnon1(fdu); - spinwait(1000); /* 1 sec */ - out_fdc(fdcu,NE7CMD_RECAL); /* Recalibrate Function */ - out_fdc(fdcu,fdsu); - spinwait(1000); /* 1 sec */ - - /* anything responding */ - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - if (st0 & 0xd0) - continue; - -#endif - fd_data[fdu].track = -2; - fd_data[fdu].fdc = fdc; - fd_data[fdu].fdsu = fdsu; - printf("fd%d: unit %d type ", fdcu, fdu); - - if ((fdt & 0xf0) == RTCFDT_12M) { - printf("1.2MB 5.25in\n"); - fd_data[fdu].type = 1; - fd_data[fdu].ft = fd_types + 1; - - } - if ((fdt & 0xf0) == RTCFDT_144M) { - printf("1.44MB 3.5in\n"); - fd_data[fdu].type = 0; - fd_data[fdu].ft = fd_types + 0; - } - - fdt <<= 4; - fd_turnoff(fdu); - hdr = 1; - } - - /* Set transfer to 500kbps */ - outb(fdc->baseport+fdctl,0); /*XXX*/ -} - -int -fdsize(dev) -dev_t dev; -{ - return(0); -} - -/****************************************************************************/ -/* fdstrategy */ -/****************************************************************************/ -fdstrategy(bp) - register struct buf *bp; /* IO operation to perform */ -{ - register struct buf *dp,*dp0,*dp1; - long nblocks,blknum; - int s; - fdcu_t fdcu; - fdu_t fdu; - fdc_p fdc; - fd_p fd; - - fdu = FDUNIT(minor(bp->b_dev)); - fd = &fd_data[fdu]; - fdc = fd->fdc; - fdcu = fdc->fdcu; - /*type = FDTYPE(minor(bp->b_dev));*/ - - if ((fdu >= NFD) || (bp->b_blkno < 0)) { - printf("fdstrat: fdu = %d, blkno = %d, bcount = %d\n", - fdu, bp->b_blkno, bp->b_bcount); - pg("fd:error in fdstrategy"); - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - goto bad; - } - /* - * Set up block calculations. - */ - blknum = (unsigned long) bp->b_blkno * DEV_BSIZE/FDBLK; - nblocks = fd->ft->size; - if (blknum + (bp->b_bcount / FDBLK) > nblocks) { - if (blknum == nblocks) { - bp->b_resid = bp->b_bcount; - } else { - bp->b_error = ENOSPC; - bp->b_flags |= B_ERROR; - } - goto bad; - } - bp->b_cylin = blknum / (fd->ft->sectrac * fd->ft->heads); - dp = &(fdc->head); - s = splbio(); - disksort(dp, bp); - untimeout(fd_turnoff,fdu); /* a good idea */ - fdstart(fdcu); - splx(s); - return; - -bad: - biodone(bp); -} - -/****************************************************************************/ -/* motor control stuff */ -/* remember to not deselect the drive we're working on */ -/****************************************************************************/ -set_motor(fdcu_t fdcu, fdu_t fdu, int reset) -{ - int m0,m1; - int selunit; - fd_p fd; - if(fd = fdc_data[fdcu].fd)/* yes an assign! */ - { - selunit = fd->fdsu; - } - else - { - selunit = 0; - } - m0 = fd_data[fdcu * DRVS_PER_CTLR + 0].flags & FD_MOTOR; - m1 = fd_data[fdcu * DRVS_PER_CTLR + 1].flags & FD_MOTOR; - outb(fdc_data[fdcu].baseport+fdout, - selunit - | (reset ? 0 : (FDO_FRST|FDO_FDMAEN)) - | (m0 ? FDO_MOEN0 : 0) - | (m1 ? FDO_MOEN1 : 0)); - TRACE1("[0x%x->fdout]",( - selunit - | (reset ? 0 : (FDO_FRST|FDO_FDMAEN)) - | (m0 ? FDO_MOEN0 : 0) - | (m1 ? FDO_MOEN1 : 0))); -} - -fd_turnoff(fdu_t fdu) -{ - fd_p fd = fd_data + fdu; - fd->flags &= ~FD_MOTOR; - set_motor(fd->fdc->fdcu,fd->fdsu,0); -} - -fd_motor_on(fdu_t fdu) -{ - fd_p fd = fd_data + fdu; - fd->flags &= ~FD_MOTOR_WAIT; - if((fd->fdc->fd == fd) && (fd->fdc->state == MOTORWAIT)) - { - fd_pseudointr(fd->fdc->fdcu); - } -} - -fd_turnon(fdu_t fdu) -{ - fd_p fd = fd_data + fdu; - if(!(fd->flags & FD_MOTOR)) - { - fd_turnon1(fdu); - fd->flags |= FD_MOTOR_WAIT; - timeout(fd_motor_on,fdu,hz); /* in 1 sec its ok */ - } -} - -fd_turnon1(fdu_t fdu) -{ - fd_p fd = fd_data + fdu; - fd->flags |= FD_MOTOR; - set_motor(fd->fdc->fdcu,fd->fdsu,0); -} - -/****************************************************************************/ -/* fdc in/out */ -/****************************************************************************/ -int -in_fdc(fdcu_t fdcu) -{ - int baseport = fdc_data[fdcu].baseport; - int i, j = 100000; - while ((i = inb(baseport+fdsts) & (NE7_DIO|NE7_RQM)) - != (NE7_DIO|NE7_RQM) && j-- > 0) - if (i == NE7_RQM) return -1; - if (j <= 0) - return(-1); -#ifdef DEBUG - i = inb(baseport+fddata); - TRACE1("[fddata->0x%x]",(unsigned char)i); - return(i); -#else - return inb(baseport+fddata); -#endif -} - -out_fdc(fdcu_t fdcu,int x) -{ - int baseport = fdc_data[fdcu].baseport; - int i = 100000; - - while ((inb(baseport+fdsts) & NE7_DIO) && i-- > 0); - while ((inb(baseport+fdsts) & NE7_RQM) == 0 && i-- > 0); - if (i <= 0) return (-1); - outb(baseport+fddata,x); - TRACE1("[0x%x->fddata]",x); - return (0); -} - -static fdopenf; -/****************************************************************************/ -/* fdopen/fdclose */ -/****************************************************************************/ -Fdopen(dev, flags) - dev_t dev; - int flags; -{ - fdu_t fdu = FDUNIT(minor(dev)); - /*int type = FDTYPE(minor(dev));*/ - int s; - - /* check bounds */ - if (fdu >= NFD) return(ENXIO); - /*if (type >= NUMTYPES) return(ENXIO);*/ - fd_data[fdu].flags |= FD_OPEN; - - return 0; -} - -fdclose(dev, flags) - dev_t dev; -{ - fdu_t fdu = FDUNIT(minor(dev)); - fd_data[fdu].flags &= ~FD_OPEN; - return(0); -} - - -/***************************************************************\ -* fdstart * -* We have just queued something.. if the controller is not busy * -* then simulate the case where it has just finished a command * -* So that it (the interrupt routine) looks on the queue for more* -* work to do and picks up what we just added. * -* If the controller is already busy, we need do nothing, as it * -* will pick up our work when the present work completes * -\***************************************************************/ -fdstart(fdcu_t fdcu) -{ - register struct buf *dp,*bp; - int s; - fdu_t fdu; - - s = splbio(); - if(fdc_data[fdcu].state == DEVIDLE) - { - fdintr(fdcu); - } - splx(s); -} - -fd_timeout(fdcu_t fdcu) -{ - fdu_t fdu = fdc_data[fdcu].fdu; - int st0, st3, cyl; - struct buf *dp,*bp; - - dp = &fdc_data[fdcu].head; - bp = dp->b_actf; - - out_fdc(fdcu,NE7CMD_SENSED); - out_fdc(fdcu,fd_data[fdu].hddrv); - st3 = in_fdc(fdcu); - - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - printf("fd%d: Operation timeout ST0 %b cyl %d ST3 %b\n", - fdu, - st0, - NE7_ST0BITS, - cyl, - st3, - NE7_ST3BITS); - - if (bp) - { - retrier(fdcu); - fdc_data[fdcu].status[0] = 0xc0; - fdc_data[fdcu].state = IOTIMEDOUT; - if( fdc_data[fdcu].retry < 6) - fdc_data[fdcu].retry = 6; - } - else - { - fdc_data[fdcu].fd = (fd_p) 0; - fdc_data[fdcu].fdu = -1; - fdc_data[fdcu].state = DEVIDLE; - } - fd_pseudointr(fdcu); -} - -/* just ensure it has the right spl */ -fd_pseudointr(fdcu_t fdcu) -{ - int s; - s = splbio(); - fdintr(fdcu); - splx(s); -} - -/***********************************************************************\ -* fdintr * -* keep calling the state machine until it returns a 0 * -* ALWAYS called at SPLBIO * -\***********************************************************************/ -fdintr(fdcu_t fdcu) -{ - fdc_p fdc = fdc_data + fdcu; - while(fdstate(fdcu, fdc)); -} - -/***********************************************************************\ -* The controller state machine. * -* if it returns a non zero value, it should be called again immediatly * -\***********************************************************************/ -int fdstate(fdcu_t fdcu, fdc_p fdc) -{ - int read,head,trac,sec,i,s,sectrac,cyl,st0; - unsigned long blknum; - fdu_t fdu = fdc->fdu; - fd_p fd; - register struct buf *dp,*bp; - - dp = &(fdc->head); - bp = dp->b_actf; - if(!bp) - { - /***********************************************\ - * nothing left for this controller to do * - * Force into the IDLE state, * - \***********************************************/ - fdc->state = DEVIDLE; - if(fdc->fd) - { - printf("unexpected valid fd pointer (fdu = %d)\n" - ,fdc->fdu); - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - } - TRACE1("[fdc%d IDLE]",fdcu); - return(0); - } - fdu = FDUNIT(minor(bp->b_dev)); - fd = fd_data + fdu; - if (fdc->fd && (fd != fdc->fd)) - { - printf("confused fd pointers\n"); - } - read = bp->b_flags & B_READ; - TRACE1("fd%d",fdu); - TRACE1("[%s]",fdstates[fdc->state]); - TRACE1("(0x%x)",fd->flags); - untimeout(fd_turnoff, fdu); - timeout(fd_turnoff,fdu,4 * hz); - switch (fdc->state) - { - case DEVIDLE: - case FINDWORK: /* we have found new work */ - fdc->retry = 0; - fd->skip = 0; - fdc->fd = fd; - fdc->fdu = fdu; - /*******************************************************\ - * If the next drive has a motor startup pending, then * - * it will start up in it's own good time * - \*******************************************************/ - if(fd->flags & FD_MOTOR_WAIT) - { - fdc->state = MOTORWAIT; - return(0); /* come back later */ - } - /*******************************************************\ - * Maybe if it's not starting, it SHOULD be starting * - \*******************************************************/ - if (!(fd->flags & FD_MOTOR)) - { - fdc->state = MOTORWAIT; - fd_turnon(fdu); - return(0); - } - else /* at least make sure we are selected */ - { - set_motor(fdcu,fd->fdsu,0); - } - fdc->state = DOSEEK; - break; - case DOSEEK: - if (bp->b_cylin == fd->track) - { - fdc->state = SEEKCOMPLETE; - break; - } - out_fdc(fdcu,NE7CMD_SEEK); /* Seek function */ - out_fdc(fdcu,fd->fdsu); /* Drive number */ - out_fdc(fdcu,bp->b_cylin * fd->ft->steptrac); - fd->track = -2; - fdc->state = SEEKWAIT; - return(0); /* will return later */ - case SEEKWAIT: - /* allow heads to settle */ - timeout(fd_pseudointr,fdcu,hz/50); - fdc->state = SEEKCOMPLETE; - return(0); /* will return later */ - break; - - case SEEKCOMPLETE : /* SEEK DONE, START DMA */ - /* Make sure seek really happened*/ - if(fd->track == -2) - { - int descyl = bp->b_cylin * fd->ft->steptrac; - out_fdc(fdcu,NE7CMD_SENSEI); - i = in_fdc(fdcu); - cyl = in_fdc(fdcu); - if (cyl != descyl) - { - printf("fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n", fdu, - descyl, cyl, i, NE7_ST0BITS); - return(retrier(fdcu)); - } - } - - fd->track = bp->b_cylin; - isa_dmastart(bp->b_flags, bp->b_un.b_addr+fd->skip, - FDBLK, fdc->dmachan); - blknum = (unsigned long)bp->b_blkno*DEV_BSIZE/FDBLK - + fd->skip/FDBLK; - sectrac = fd->ft->sectrac; - sec = blknum % (sectrac * fd->ft->heads); - head = sec / sectrac; - sec = sec % sectrac + 1; -/*XXX*/ fd->hddrv = ((head&1)<<2)+fdu; - - if (read) - { - out_fdc(fdcu,NE7CMD_READ); /* READ */ - } - else - { - out_fdc(fdcu,NE7CMD_WRITE); /* WRITE */ - } - out_fdc(fdcu,head << 2 | fdu); /* head & unit */ - out_fdc(fdcu,fd->track); /* track */ - out_fdc(fdcu,head); - out_fdc(fdcu,sec); /* sector XXX +1? */ - out_fdc(fdcu,fd->ft->secsize); /* sector size */ - out_fdc(fdcu,sectrac); /* sectors/track */ - out_fdc(fdcu,fd->ft->gap); /* gap size */ - out_fdc(fdcu,fd->ft->datalen); /* data length */ - fdc->state = IOCOMPLETE; - timeout(fd_timeout,fdcu,2 * hz); - return(0); /* will return later */ - case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fd_timeout,fdcu); - for(i=0;i<7;i++) - { - fdc->status[i] = in_fdc(fdcu); - } - case IOTIMEDOUT: /*XXX*/ - isa_dmadone(bp->b_flags, bp->b_un.b_addr+fd->skip, - FDBLK, fdc->dmachan); - if (fdc->status[0]&0xF8) - { - return(retrier(fdcu)); - } - /* All OK */ - fd->skip += FDBLK; - if (fd->skip < bp->b_bcount) - { - /* set up next transfer */ - blknum = (unsigned long)bp->b_blkno*DEV_BSIZE/FDBLK - + fd->skip/FDBLK; - bp->b_cylin = (blknum / (fd->ft->sectrac * fd->ft->heads)); - fdc->state = DOSEEK; - } - else - { - /* ALL DONE */ - fd->skip = 0; - bp->b_resid = 0; - dp->b_actf = bp->av_forw; - biodone(bp); - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - fdc->state = FINDWORK; - } - return(1); - case RESETCTLR: - /* Try a reset, keep motor on */ - set_motor(fdcu,fd->fdsu,1); - DELAY(100); - set_motor(fdcu,fd->fdsu,0); - outb(fdc->baseport+fdctl,fd->ft->trans); - TRACE1("[0x%x->fdctl]",fd->ft->trans); - fdc->retry++; - fdc->state = STARTRECAL; - break; - case STARTRECAL: - out_fdc(fdcu,NE7CMD_SPECIFY); /* specify command */ - out_fdc(fdcu,0xDF); - out_fdc(fdcu,2); - out_fdc(fdcu,NE7CMD_RECAL); /* Recalibrate Function */ - out_fdc(fdcu,fdu); - fdc->state = RECALWAIT; - return(0); /* will return later */ - case RECALWAIT: - /* allow heads to settle */ - timeout(fd_pseudointr,fdcu,hz/30); - fdc->state = RECALCOMPLETE; - return(0); /* will return later */ - case RECALCOMPLETE: - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - if (cyl != 0) - { - printf("fd%d: recal failed ST0 %b cyl %d\n", fdu, - st0, NE7_ST0BITS, cyl); - return(retrier(fdcu)); - } - fd->track = 0; - /* Seek (probably) necessary */ - fdc->state = DOSEEK; - return(1); /* will return immediatly */ - case MOTORWAIT: - if(fd->flags & FD_MOTOR_WAIT) - { - return(0); /* time's not up yet */ - } - fdc->state = DOSEEK; - return(1); /* will return immediatly */ - default: - printf("Unexpected FD int->"); - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - printf("ST0 = %lx, PCN = %lx\n",i,sec); - out_fdc(fdcu,0x4A); - out_fdc(fdcu,fd->fdsu); - for(i=0;i<7;i++) { - fdc->status[i] = in_fdc(fdcu); - } - printf("intr status :%lx %lx %lx %lx %lx %lx %lx ", - fdc->status[0], - fdc->status[1], - fdc->status[2], - fdc->status[3], - fdc->status[4], - fdc->status[5], - fdc->status[6] ); - return(0); - } - return(1); /* Come back immediatly to new state */ -} - -retrier(fdcu_t fdcu) -{ - fdc_p fdc = fdc_data + fdcu; - register struct buf *dp,*bp; - - dp = &(fdc->head); - bp = dp->b_actf; - - switch(fdc->retry) - { - case 0: case 1: case 2: - fdc->state = SEEKCOMPLETE; - break; - case 3: case 4: case 5: - fdc->state = STARTRECAL; - break; - case 6: - fdc->state = RESETCTLR; - break; - case 7: - break; - default: - { - printf("fd%d: hard error (ST0 %b ", - fdc->fdu, fdc->status[0], NE7_ST0BITS); - printf(" ST1 %b ", fdc->status[1], NE7_ST1BITS); - printf(" ST2 %b ", fdc->status[2], NE7_ST2BITS); - printf(" ST3 %b ", fdc->status[3], NE7_ST3BITS); - printf("cyl %d hd %d sec %d)\n", - fdc->status[4], fdc->status[5], fdc->status[6]); - } - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - bp->b_resid = bp->b_bcount - fdc->fd->skip; - dp->b_actf = bp->av_forw; - fdc->fd->skip = 0; - biodone(bp); - fdc->state = FINDWORK; - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - return(1); - } - fdc->retry++; - return(1); -} - -#endif - diff --git a/sys/dev/fdc/fdcreg.h b/sys/dev/fdc/fdcreg.h deleted file mode 100644 index 948f566..0000000 --- a/sys/dev/fdc/fdcreg.h +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)fdreg.h 7.1 (Berkeley) 5/9/91 - * - * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE - * -------------------- ----- ---------------------- - * CURRENT PATCH LEVEL: 1 00153 - * -------------------- ----- ---------------------- - * - * 20 Apr 93 Julian Elischer Heavily re worked, see notes below - */ - -/* - * AT floppy controller registers and bitfields - */ - -/* uses NEC765 controller */ -#include "../i386/isa/ic/nec765.h" - -/* registers */ -#define fdout 2 /* Digital Output Register (W) */ -#define FDO_FDSEL 0x03 /* floppy device select */ -#define FDO_FRST 0x04 /* floppy controller reset */ -#define FDO_FDMAEN 0x08 /* enable floppy DMA and Interrupt */ -#define FDO_MOEN0 0x10 /* motor enable drive 0 */ -#define FDO_MOEN1 0x20 /* motor enable drive 1 */ -#define FDO_MOEN2 0x30 /* motor enable drive 2 */ -#define FDO_MOEN3 0x40 /* motor enable drive 3 */ - -#define fdsts 4 /* NEC 765 Main Status Register (R) */ -#define fddata 5 /* NEC 765 Data Register (R/W) */ - -#define fdctl 7 /* Control Register (W) */ -#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */ -#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */ -#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */ -#define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */ - -#define fdin 7 /* Digital Input Register (R) */ -#define FDI_DCHG 0x80 /* diskette has been changed */ - - diff --git a/sys/dev/ic/i8237.h b/sys/dev/ic/i8237.h deleted file mode 100644 index dc269f2..0000000 --- a/sys/dev/ic/i8237.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Intel 8237 DMA Controller - */ - -#define DMA37MD_SINGLE 0x40 /* single pass mode */ -#define DMA37MD_CASCADE 0xc0 /* cascade mode */ -#define DMA37MD_WRITE 0x04 /* read the device, write memory operation */ -#define DMA37MD_READ 0x08 /* write the device, read memory operation */ - diff --git a/sys/dev/ic/nec765.h b/sys/dev/ic/nec765.h deleted file mode 100644 index b84b46e..0000000 --- a/sys/dev/ic/nec765.h +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nec765.h 7.1 (Berkeley) 5/9/91 - */ - -/* - * Nec 765 floppy disc controller definitions - */ - -/* Main status register */ -#define NE7_DAB 0x01 /* Diskette drive A is seeking, thus busy */ -#define NE7_DBB 0x02 /* Diskette drive B is seeking, thus busy */ -#define NE7_CB 0x10 /* Diskette Controller Busy */ -#define NE7_NDM 0x20 /* Diskette Controller in Non Dma Mode */ -#define NE7_DIO 0x40 /* Diskette Controller Data register I/O */ -#define NE7_RQM 0x80 /* Diskette Controller ReQuest for Master */ - -/* Status register ST0 */ -#define NE7_ST0BITS "\020\010invld\007abnrml\006seek_cmplt\005drv_chck\004drive_rdy\003top_head" - -/* Status register ST1 */ -#define NE7_ST1BITS "\020\010end_of_cyl\006bad_crc\005data_overrun\003sec_not_fnd\002write_protect\001no_am" - -/* Status register ST2 */ -#define NE7_ST2BITS "\020\007ctrl_mrk\006bad_crc\005wrong_cyl\004scn_eq\003scn_not_fnd\002bad_cyl\001no_dam" - -/* Status register ST3 */ -#define NE7_ST3BITS "\020\010fault\007write_protect\006drdy\005tk0\004two_side\003side_sel\002" - -/* Commands */ -#define NE7CMD_SPECIFY 3 /* specify drive parameters - requires unit - parameters byte */ -#define NE7CMD_SENSED 4 /* sense drive - requires unit select byte */ -#define NE7CMD_WRITE 0xc5 /* write - requires eight additional bytes */ -#define NE7CMD_READ 0xe6 /* read - requires eight additional bytes */ -#define NE7CMD_FORMAT 0x4c /* format - requires five additional bytes */ -#define NE7CMD_RECAL 7 /* recalibrate drive - requires - unit select byte */ -#define NE7CMD_SENSEI 8 /* sense controller interrupt status */ -#define NE7CMD_SEEK 15 /* seek drive - requires unit select byte - and new cyl byte */ diff --git a/sys/dev/ic/ns16550.h b/sys/dev/ic/ns16550.h deleted file mode 100644 index e20e9aa..0000000 --- a/sys/dev/ic/ns16550.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ns16550.h 7.1 (Berkeley) 5/9/91 - */ - -/* - * NS16550 UART registers - */ - -#define com_data 0 /* data register (R/W) */ -#define com_dlbl 0 /* divisor latch low (W) */ -#define com_dlbh 1 /* divisor latch high (W) */ -#define com_ier 1 /* interrupt enable (W) */ -#define com_iir 2 /* interrupt identification (R) */ -#define com_fifo 2 /* FIFO control (W) */ -#define com_lctl 3 /* line control register (R/W) */ -#define com_cfcr 3 /* line control register (R/W) */ -#define com_mcr 4 /* modem control register (R/W) */ -#define com_lsr 5 /* line status register (R/W) */ -#define com_msr 6 /* modem status register (R/W) */ diff --git a/sys/dev/kbd/kbdtables.h b/sys/dev/kbd/kbdtables.h deleted file mode 100644 index 45df7f5..0000000 --- a/sys/dev/kbd/kbdtables.h +++ /dev/null @@ -1,856 +0,0 @@ -/* - * Copyright (C) 1992, 1993 Søren Schmidt - * - * This program is free software; you may redistribute it and/or - * modify it, provided that it retain the above copyright notice - * and the following disclaimer. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Søren Schmidt Email: sos@kmd-ac.dk - * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos - * DK9210 Aalborg SO Phone: +45 9814 8076 - */ - -#define META 0x80 /* eight bit for emacs META-key */ - -#ifdef DKKEYMAP -keymap_t key_map = { 0x69, /* DK iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '"', 0x00, 0x00, '@', '"', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', '#', NOP, NOP, 0x9E, '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', 0xA4, NOP, NOP, '$', 0xA4, NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '&', NOP, NOP, '6', '&', NOP, NOP, 0x33, 0x00, -/* sc=08 */ '7', '/', NOP, NOP, '{', '/', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '8', '(', 0x1B, 0x1B, '[', '(', 0x1B, 0x1B, 0x00, 0x00, -/* sc=0a */ '9', ')', 0x1D, 0x1D, ']', ')', 0x1D, 0x1D, 0x00, 0x00, -/* sc=0b */ '0', '=', NOP, NOP, '}', '=', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '+', '?', NOP, NOP, '+', '?', NOP, NOP, 0x33, 0x00, -/* sc=0d */ '\'', '`', NOP, NOP, '|', '`', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x33, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ 0xE5, 0xC5, NOP, NOP, 0x86, 0x8F, NOP, NOP, 0x33, 0x01, -/* sc=1b */ '"', '^', 0x1E, 0x1E, '~', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ 0xE6, 0xC6, NOP, NOP, 0x91, 0x92, NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xF8, 0xD8, NOP, NOP, 0x9B, 0x9D, NOP, NOP, 0x33, 0x01, -/* sc=29 */ 0xBD, 0xA7, NOP, NOP, 0xBD, 0xA7, NOP, NOP, 0x33, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\'', '*', NOP, NOP, '\'', '*', NOP, NOP, 0x33, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', ';', NOP, NOP, ',', ';', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', ':', NOP, NOP, '.', ':', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', '*', '*', '*', '*', '*', '*', 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ NOP, '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', '.', '.', '.', '.', '.', '.', 0x00, 0x02, -/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ '<', '>', 0x1C, 0x1C, '\\', '>', 0x1C, 0x1C, 0x00, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x00, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef UKKEYMAP -keymap_t keymap = { 0x69, /* uk iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', 0xA3, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '^', 0x1E, 0x1E, '^', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=08 */ '7', '&', NOP, NOP, '[', '[', 0x1B, 0x1B, 0x30, 0x00, -/* sc=09 */ '8', '*', NOP, NOP, '8', '*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', '(', NOP, NOP, ']', ']', 0x1D, 0x1D, 0x30, 0x00, -/* sc=0b */ '0', ')', NOP, NOP, '{', '{', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '-', '_', 0x1F, 0x1F, '|', '|', 0x1F, 0x1F, 0x00, 0x00, -/* sc=0d */ '=', '+', NOP, NOP, '}', '}', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x00, -/* sc=1b */ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ ';', ':', NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x00, -/* sc=28 */ '\'', '@', 0x00, 0x00, '\'', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=29 */ '\\', '|', 0x1C, 0x1C, '\\', '\\', 0x1C, 0x1C, 0x00, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '#', '~', NOP, NOP, '~', '~', NOP, NOP, 0x33, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', '<', NOP, NOP, ',', '<', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', '>', NOP, NOP, '.', '>', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '/', '?', NOP, NOP, '/', '?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00, -/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x02, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef GRKEYMAP -keymap_t keymap = { 0x69, /* german iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', 0xA7, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '&', 0x1E, 0x1E, '^', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=08 */ '7', '/', 0x1B, 0x1B, '[', '[', 0x1B, 0x1B, 0x00, 0x00, -/* sc=09 */ '8', '(', NOP, NOP, '8', '(', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', ')', 0x1D, 0x1D, ']', ']', 0x1D, 0x1D, 0x00, 0x00, -/* sc=0b */ '0', '=', NOP, NOP, '{', '{', NOP, NOP, 0x33, 0x00, -/* sc=0c */ 0xDF, '?', NOP, NOP, '|', '|', NOP, NOP, 0x33, 0x00, -/* sc=0d */ 0x92, 0x93, NOP, NOP, '\'', '`', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ 0xFC, 0xDC, 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x01, -/* sc=1b */ '+', '*', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ 0xF6, 0xD6, NOP, NOP, 0xF6, 0xD6, NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xE4, 0xC4, NOP, NOP, 0xE4, 0xC4, NOP, NOP, 0x33, 0x01, -/* sc=29 */ '<', '>', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '#', '^', 0x1E, 0x1E, '`', '~', 0x1E, 0x1E, 0x00, 0x00, -/* sc=2c */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', ';', NOP, NOP, ',', ';', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', ':', NOP, NOP, '.', ':', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00, -/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x02, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef SWKEYMAP -keymap_t keymap = { 0x69, /* swedish iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00, -/* sc=03 */ '2', '"', NOP, NOP, NOP, '@', NOP, NOP, 0x3B, 0x00, -/* sc=04 */ '3', 0xA3, NOP, NOP, NOP, '#', NOP, NOP, 0x3B, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00, -/* sc=07 */ '6', '&', 0x1E, NOP, NOP, '^', 0x1E, NOP, 0x19, 0x00, -/* sc=08 */ '7', '/', NOP, NOP, NOP, '&', NOP, NOP, 0x3B, 0x00, -/* sc=09 */ '8', '(', NOP, NOP, NOP, '*', NOP, NOP, 0x3B, 0x00, -/* sc=0a */ '9', ')', NOP, NOP, NOP, '(', NOP, NOP, 0x3B, 0x00, -/* sc=0b */ '0', '=', NOP, NOP, NOP, ')', NOP, NOP, 0x3B, 0x00, -/* sc=0c */ '+', '?', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=0d */ 0xB4, '`', NOP, NOP, '=', '+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ 0xE5, 0xC5, NOP, NOP, '[', '{', 0x1B, NOP, 0x31, 0x01, -/* sc=1b */ 0xA8, '^', NOP, NOP, ']', '}', 0x1D, NOP, 0x31, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ 0xF8, 0xD8, NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xE6, 0xC6, NOP, NOP, '\'', '"', NOP, NOP, 0x33, 0x01, -/* sc=29 */ '<', '>', NOP, NOP, '\\', '|', 0x1C, NOP, 0x31, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\'', '*', NOP, NOP, '`', '~', NOP, NOP, 0x33, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', ';', NOP, NOP, NOP, '<', NOP, NOP, 0x3B, 0x00, -/* sc=34 */ '.', ':', NOP, NOP, NOP, '>', NOP, NOP, 0x3B, 0x00, -/* sc=35 */ '-', '_', 0x1F, NOP, '/', '?', NOP, NOP, 0x13, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00, -/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x02, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef RUKEYMAP -keymap_t keymap = { 0xe9, /* keys number */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * ------------------------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, META|0x1B, META|0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, META|'1', META|'!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '@', 0x00, 0x00, META|'2', META|'@', META|0x00, META|0x00, 0x00, 0x00, -/* sc=04 */ '3', '#', NOP, NOP, META|'3', META|'#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, META|'4', META|'$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, META|'5', META|'%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '^', 0x1E, 0x1E, META|'6', META|'^', META|0x1E, META|0x1E, 0x00, 0x00, -/* sc=08 */ '7', '&', NOP, NOP, META|'7', META|'&', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '8', '*', NOP, NOP, META|'8', META|'*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', '(', NOP, NOP, META|'9', META|'(', NOP, NOP, 0x33, 0x00, -/* sc=0b */ '0', ')', NOP, NOP, META|'0', META|')', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '-', '_', 0x1F, 0x1F, META|'-', META|'_', META|0x1F, META|0x1F, 0x00, 0x00, -/* sc=0d */ '=', '+', NOP, NOP, META|'=', META|'+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, META|0x08, META|0x08, META|0x7F, META|0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, F(16), NOP, NOP, META|0x09, F(16), NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, META|'q', META|'Q', META|0x11, META|0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, META|'w', META|'W', META|0x17, META|0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, META|'e', META|'E', META|0x05, META|0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, META|'r', META|'R', META|0x12, META|0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, META|'t', META|'T', META|0x14, META|0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, META|'y', META|'Y', META|0x19, META|0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, META|'u', META|'U', META|0x15, META|0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, META|'i', META|'I', META|0x09, META|0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, META|'o', META|'O', META|0x0F, META|0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, META|'p', META|'P', META|0x10, META|0x10, 0x00, 0x01, -/* sc=1a */ '[', '{', 0x1B, 0x1B, META|'[', META|'{', META|0x1B, META|0x1B, 0x00, 0x00, -/* sc=1b */ ']', '}', 0x1D, 0x1D, META|']', META|'}', META|0x1D, META|0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, META|'a', META|'A', META|0x01, META|0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, META|'s', META|'S', META|0x13, META|0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, META|'d', META|'D', META|0x04, META|0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, META|'f', META|'F', META|0x06, META|0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, META|'g', META|'G', META|0x07, META|0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, META|'h', META|'H', META|0x08, META|0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, META|'j', META|'J', META|0x0A, META|0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, META|'k', META|'K', META|0x0B, META|0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, META|'l', META|'L', META|0x0C, META|0x0C, 0x00, 0x01, -/* sc=27 */ ';', ':', NOP, NOP, META|';', META|':', NOP, NOP, 0x33, 0x00, -/* sc=28 */ '\'', '"', NOP, NOP, META|'\'', META|'"', NOP, NOP, 0x33, 0x00, -/* sc=29 */ '`', '~', NOP, NOP, META|'`', META|'~', NOP, NOP, 0x33, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\\', '|', 0x1C, 0x1C, META|'\\', META|'|', META|0x1C, META|0x1C, 0x00, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, META|'z', META|'Z', META|0x1A, META|0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, META|'x', META|'X', META|0x18, META|0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, META|'c', META|'C', META|0x03, META|0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, META|'v', META|'V', META|0x16, META|0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, META|'b', META|'B', META|0x02, META|0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, META|'n', META|'N', META|0x0E, META|0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, META|'m', META|'M', META|0x0D, META|0x0D, 0x00, 0x01, -/* sc=33 */ ',', '<', NOP, NOP, META|',', META|'<', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', '>', NOP, NOP, META|'.', META|'>', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '/', '?', NOP, NOP, META|'/', META|'?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, META|'*', META|'*', META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', META|' ', META|' ', META|' ', META|' ', 0x00, 0x00, -/* sc=3a */ ALK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', META|'7', META|'7', META|'7', META|'7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', META|'8', META|'8', META|'8', META|'8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', META|'9', META|'9', META|'9', META|'9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', META|'-', META|'-', META|'-', META|'-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', META|'4', META|'4', META|'4', META|'4', 0x80, 0x02, -/* sc=4c */ F(48), '5', '5', '5', META|'5', META|'5', META|'5', META|'5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', META|'6', META|'6', META|'6', META|'6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', META|'+', META|'+', META|'+', META|'+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', META|'1', META|'1', META|'1', META|'1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', META|'2', META|'2', META|'2', META|'2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', META|'3', META|'3', META|'3', META|'3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', META|'0', META|'0', META|'0', META|'0', 0x80, 0x02, -/* sc=53 */ F(54), '.', 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0x80, 0x02, -/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', NOP, NOP, META|'/', META|'/', NOP, NOP, 0x33, 0x00, -/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0xC0, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=69 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6b */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=70 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=71 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=72 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=73 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=74 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=75 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=76 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=77 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=78 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=79 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7b */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* extended (ALTGR LOCK keys) */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, META|0x1B, META|0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '!', '1', NOP, NOP, META|'1', META|'!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '"', '2', 0x00, 0x00, META|'2', META|'@', META|0x00, META|0x00, 0x00, 0x00, -/* sc=04 */ '\'', '3', NOP, NOP, META|'3', META|'#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ ';', '4', NOP, NOP, META|'4', META|'$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ ':', '5', NOP, NOP, META|'5', META|'%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ ',', '6', 0x1E, 0x1E, META|'6', META|'^', META|0x1E, META|0x1E, 0x00, 0x00, -/* sc=08 */ '.', '7', NOP, NOP, META|'7', META|'&', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '*', '8', NOP, NOP, META|'8', META|'*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '(', '9', NOP, NOP, META|'9', META|'(', NOP, NOP, 0x33, 0x00, -/* sc=0b */ ')', '0', NOP, NOP, META|'0', META|')', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '_', '-', 0x1F, 0x1F, META|'-', META|'_', META|0x1F, META|0x1F, 0x00, 0x00, -/* sc=0d */ '+', '=', NOP, NOP, META|'=', META|'+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, META|0x08, META|0x08, META|0x7F, META|0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, F(16), NOP, NOP, META|0x09, F(16), NOP, NOP, 0x77, 0x00, -/* sc=10 */ 0xca, 0xea, 0x11, 0x11, META|'q', META|'Q', META|0x11, META|0x11, 0x00, 0x01, -/* sc=11 */ 0xc3, 0xe3, 0x17, 0x17, META|'w', META|'W', META|0x17, META|0x17, 0x00, 0x01, -/* sc=12 */ 0xd5, 0xf5, 0x05, 0x05, META|'e', META|'E', META|0x05, META|0x05, 0x00, 0x01, -/* sc=13 */ 0xcb, 0xeb, 0x12, 0x12, META|'r', META|'R', META|0x12, META|0x12, 0x00, 0x01, -/* sc=14 */ 0xc5, 0xe5, 0x14, 0x14, META|'t', META|'T', META|0x14, META|0x14, 0x00, 0x01, -/* sc=15 */ 0xce, 0xee, 0x19, 0x19, META|'y', META|'Y', META|0x19, META|0x19, 0x00, 0x01, -/* sc=16 */ 0xc7, 0xe7, 0x15, 0x15, META|'u', META|'U', META|0x15, META|0x15, 0x00, 0x01, -/* sc=17 */ 0xdb, 0xfb, 0x09, 0x09, META|'i', META|'I', META|0x09, META|0x09, 0x00, 0x01, -/* sc=18 */ 0xdd, 0xfd, 0x0F, 0x0F, META|'o', META|'O', META|0x0F, META|0x0F, 0x00, 0x01, -/* sc=19 */ 0xda, 0xfa, 0x10, 0x10, META|'p', META|'P', META|0x10, META|0x10, 0x00, 0x01, -/* sc=1a */ 0xc8, 0xe8, 0x1B, 0x1B, META|'[', META|'{', META|0x1B, META|0x1B, 0x00, 0x01, -/* sc=1b */ 0xdf, 0xff, 0x1D, 0x1D, META|']', META|'}', META|0x1D, META|0x1D, 0x00, 0x01, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 0xc6, 0xe6, 0x01, 0x01, META|'a', META|'A', META|0x01, META|0x01, 0x00, 0x01, -/* sc=1f */ 0xd9, 0xf9, 0x13, 0x13, META|'s', META|'S', META|0x13, META|0x13, 0x00, 0x01, -/* sc=20 */ 0xd7, 0xf7, 0x04, 0x04, META|'d', META|'D', META|0x04, META|0x04, 0x00, 0x01, -/* sc=21 */ 0xc1, 0xe1, 0x06, 0x06, META|'f', META|'F', META|0x06, META|0x06, 0x00, 0x01, -/* sc=22 */ 0xd0, 0xf0, 0x07, 0x07, META|'g', META|'G', META|0x07, META|0x07, 0x00, 0x01, -/* sc=23 */ 0xd2, 0xf2, 0x08, 0x08, META|'h', META|'H', META|0x08, META|0x08, 0x00, 0x01, -/* sc=24 */ 0xcf, 0xef, 0x0A, 0x0A, META|'j', META|'J', META|0x0A, META|0x0A, 0x00, 0x01, -/* sc=25 */ 0xcc, 0xec, 0x0B, 0x0B, META|'k', META|'K', META|0x0B, META|0x0B, 0x00, 0x01, -/* sc=26 */ 0xc4, 0xe4, 0x0C, 0x0C, META|'l', META|'L', META|0x0C, META|0x0C, 0x00, 0x01, -/* sc=27 */ 0xd6, 0xf6, NOP, NOP, META|';', META|':', NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xdc, 0xfc, NOP, NOP, META|'\'', META|'"', NOP, NOP, 0x33, 0x01, -/* sc=29 */ 0xa3, 0xb3, NOP, NOP, META|'`', META|'~', NOP, NOP, 0x33, 0x01, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\\', '|', 0x1C, 0x1C, META|'\\', META|'|', META|0x1C, META|0x1C, 0x00, 0x00, -/* sc=2c */ 0xd1, 0xf1, 0x1A, 0x1A, META|'z', META|'Z', META|0x1A, META|0x1A, 0x00, 0x01, -/* sc=2d */ 0xde, 0xfe, 0x18, 0x18, META|'x', META|'X', META|0x18, META|0x18, 0x00, 0x01, -/* sc=2e */ 0xd3, 0xf3, 0x03, 0x03, META|'c', META|'C', META|0x03, META|0x03, 0x00, 0x01, -/* sc=2f */ 0xcd, 0xed, 0x16, 0x16, META|'v', META|'V', META|0x16, META|0x16, 0x00, 0x01, -/* sc=30 */ 0xc9, 0xe9, 0x02, 0x02, META|'b', META|'B', META|0x02, META|0x02, 0x00, 0x01, -/* sc=31 */ 0xd4, 0xf4, 0x0E, 0x0E, META|'n', META|'N', META|0x0E, META|0x0E, 0x00, 0x01, -/* sc=32 */ 0xd8, 0xf8, 0x0D, 0x0D, META|'m', META|'M', META|0x0D, META|0x0D, 0x00, 0x01, -/* sc=33 */ 0xc2, 0xe2, NOP, NOP, META|',', META|'<', NOP, NOP, 0x33, 0x01, -/* sc=34 */ 0xc0, 0xe0, NOP, NOP, META|'.', META|'>', NOP, NOP, 0x33, 0x01, -/* sc=35 */ '/', '?', NOP, NOP, META|'/', META|'?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, META|'*', META|'*', META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', META|' ', META|' ', META|' ', META|' ', 0x00, 0x00, -/* sc=3a */ ALK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', META|'7', META|'7', META|'7', META|'7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', META|'8', META|'8', META|'8', META|'8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', META|'9', META|'9', META|'9', META|'9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', META|'-', META|'-', META|'-', META|'-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', META|'4', META|'4', META|'4', META|'4', 0x80, 0x02, -/* sc=4c */ F(48), '5', '5', '5', META|'5', META|'5', META|'5', META|'5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', META|'6', META|'6', META|'6', META|'6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', META|'+', META|'+', META|'+', META|'+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', META|'1', META|'1', META|'1', META|'1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', META|'2', META|'2', META|'2', META|'2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', META|'3', META|'3', META|'3', META|'3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', META|'0', META|'0', META|'0', META|'0', 0x80, 0x02, -/* sc=53 */ F(54), '.', 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0x80, 0x02, -/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', NOP, NOP, META|'/', META|'/', NOP, NOP, 0x33, 0x00, -/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0xC0, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; - -#endif - -#if !defined(DKKEYMAP) && !defined(UKKEYMAP) && !defined(GRKEYMAP) && !defined(SWKEYMAP) && !defined(RUKEYMAP) -keymap_t key_map = { 0x69, /* US iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '@', 0x00, 0x00, '2', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', '#', NOP, NOP, '3', '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '^', 0x1E, 0x1E, '6', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=08 */ '7', '&', NOP, NOP, '7', '&', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '8', '*', NOP, NOP, '8', '*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', '(', NOP, NOP, '9', '(', NOP, NOP, 0x33, 0x00, -/* sc=0b */ '0', ')', NOP, NOP, '0', ')', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=0d */ '=', '+', NOP, NOP, '=', '+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x33, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x00, -/* sc=1b */ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ ';', ':', NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x00, -/* sc=28 */ '\'', '"', NOP, NOP, '\'', '"', NOP, NOP, 0x33, 0x00, -/* sc=29 */ '`', '~', NOP, NOP, '`', '~', NOP, NOP, 0x33, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', '<', NOP, NOP, ',', '<', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', '>', NOP, NOP, '.', '>', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '/', '?', NOP, NOP, '/', '?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ NOP, '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x00, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; - -#endif - -fkeytab_t fkey_tab[60] = { -/* 00-03 */ {"\033[M", 3}, {"\033[N", 3}, {"\033[O", 3}, {"\033[P", 3}, -/* 04-07 */ {"\033[Q", 3}, {"\033[R", 3}, {"\033[S", 3}, {"\033[T", 3}, -/* 08-0B */ {"\033[U", 3}, {"\033[V", 3}, {"\033[W", 3}, {"\033[X", 3}, -/* 0C-0F */ {"\033[W", 3}, {"\033[X", 3}, {"\033[Y", 3}, {"\033[Z", 3}, -/* 10-13 */ {"\033[a", 3}, {"\033[b", 3}, {"\033[c", 3}, {"\033[d", 3}, -/* 14-17 */ {"\033[e", 3}, {"\033[f", 3}, {"\033[g", 3}, {"\033[h", 3}, -/* 18-1B */ {"\033[g", 3}, {"\033[h", 3}, {"\033[i", 3}, {"\033[j", 3}, -/* 1C-1F */ {"\033[k", 3}, {"\033[l", 3}, {"\033[m", 3}, {"\033[n", 3}, -/* 20-23 */ {"\033[o", 3}, {"\033[p", 3}, {"\033[q", 3}, {"\033[r", 3}, -/* 24-27 */ {"\033[g", 3}, {"\033[h", 3}, {"\033[i", 3}, {"\033[j", 3}, -/* 28-2B */ {"\033[k", 3}, {"\033[l", 3}, {"\033[m", 3}, {"\033[n", 3}, -/* 2C-2F */ {"\033[o", 3}, {"\033[p", 3}, {"\033[q", 3}, {"\033[r", 3}, -/* 30-33 */ {"\033[H", 3}, {"\033[A", 3}, {"\033[I", 3}, {"-" , 1}, -/* 34-37 */ {"\033[D", 3}, {"\177" , 1}, {"\033[C", 3}, {"+" , 1}, -/* 38-3B */ {"\033[F", 3}, {"\033[B", 3}, {"\033[G", 3}, {"\033[L", 3} -}; diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c deleted file mode 100644 index 46e32eb..0000000 --- a/sys/dev/sio/sio.c +++ /dev/null @@ -1,1721 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * From: - * @(#)com.c 7.5 (Berkeley) 5/16/91 - * - * 27 May 93 Bruce Evans From com-0.2 package, fast interrupt - * com port driver. - * 27 May 93 Guido van Rooij Ported in Chris Demetriou's BIDIR - * code, add multiport support. - * 27 May 93 Rodney W. Grimes I then renamed it to sio.c for putting - * into the patch kit. Added in sioselect - * from com.c. Added port 4 support. - */ -static char rcsid[] = "$Header: /a/cvs/386BSD/src/sys.386bsd/i386/isa/sio.c,v 1.4 1993/07/20 00:22:30 jkh Exp $"; - -#include "sio.h" -#if NSIO > 0 -/* - * COM driver, based on HP dca driver. - * Mostly rewritten to use pseudo-DMA. - * Works for National Semiconductor NS8250-NS16550AF UARTs. - */ -#include "param.h" -#include "systm.h" -#include "ioctl.h" -#include "tty.h" -#include "proc.h" -#include "user.h" -#include "conf.h" -#include "file.h" -#include "uio.h" -#include "kernel.h" -#include "syslog.h" - -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/comreg.h" -#include "i386/isa/ic/ns16550.h" - -#undef CRTS_IFLOW -#define CRTS_IFLOW CRTSCTS /* XXX, CCTS_OFLOW = CRTSCTS already */ -#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ -#define RB_I_HIGH_WATER (RBSZ - 2 * RS_IBUFSIZE) -#define RB_I_LOW_WATER ((RBSZ - 2 * RS_IBUFSIZE) * 7 / 8) -#define RS_IBUFSIZE 256 -#define TS_RTSBLOCK TS_TBLOCK /* XXX */ -#define TTY_BI TTY_FE /* XXX */ -#define TTY_OE TTY_PE /* XXX */ -#ifndef COM_BIDIR -#define UNIT(x) (minor(x)) /* XXX */ -#else /* COM_BIDIR */ -#define COM_UNITMASK 0x7f -#define COM_CALLOUTMASK 0x80 - -#define UNIT(x) (minor(x) & COM_UNITMASK) -#define CALLOUT(x) (minor(x) & COM_CALLOUTMASK) -#endif /* COM_BIDIR */ - -#ifdef COM_MULTIPORT -/* checks in flags for multiport and which is multiport "master chip" - * for a given card - */ -#define COM_ISMULTIPORT(dev) ((dev)->id_flags & 0x01) -#define COM_MPMASTER(dev) (((dev)->id_flags >> 8) & 0x0ff) -#endif /* COM_MULTIPORT */ - -#define com_scr 7 /* scratch register for 16450-16550 (R/W) */ -#define schedsoftcom() (ipending |= 1 << 4) /* XXX */ - -/* - * Input buffer watermarks. - * The external device is asked to stop sending when the buffer exactly reaches - * high water, or when the high level requests it. - * The high level is notified immediately (rather than at a later clock tick) - * when this watermark is reached. - * The buffer size is chosen so the watermark should almost never be reached. - * The low watermark is invisibly 0 since the buffer is always emptied all at - * once. - */ -#define RS_IHIGHWATER (3 * RS_IBUFSIZE / 4) - -/* - * com state bits. - * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher - * than the other bits so that they can be tested as a group without masking - * off the low bits. - * - * The following com and tty flags correspond closely: - * TS_BUSY = CS_BUSY (maintained by comstart() and comflush()) - * CS_TTGO = ~TS_TTSTOP (maintained by comstart() and siostop()) - * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) - * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) - * TS_FLUSH is not used. - * Bug: I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON. - */ -#define CS_BUSY 0x80 /* output in progress */ -#define CS_TTGO 0x40 /* output not stopped by XOFF */ -#define CS_ODEVREADY 0x20 /* external device h/w ready (CTS) */ -#define CS_CHECKMSR 1 /* check of MSR scheduled */ -#define CS_CTS_OFLOW 2 /* use CTS output flow control */ -#define CS_ODONE 4 /* output completed */ -#define CS_RTS_IFLOW 8 /* use RTS input flow control */ - -static char *error_desc[] = { -#define CE_OVERRUN 0 - "silo overflow", -#define CE_INTERRUPT_BUF_OVERFLOW 1 - "interrupt-level buffer overflow", -#define CE_TTY_BUF_OVERFLOW 2 - "tty-level buffer overflow", -}; - -#define CE_NTYPES 3 -#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum]) - -/* types. XXX - should be elsewhere */ -typedef u_int Port_t; /* hardware port */ -typedef int Bool_t; /* promoted boolean */ -typedef u_char bool_t; /* boolean */ - -/* com device structure */ -struct com_s { - u_char state; /* miscellaneous flag bits */ - u_char cfcr_image; /* copy of value written to CFCR */ - bool_t hasfifo; /* nonzero for 16550 UARTs */ - u_char mcr_image; /* copy of value written to MCR */ - bool_t softDCD; /* nonzero for faked carrier detect */ -#ifdef COM_BIDIR - bool_t bidir; /* is this unit bidirectional? */ - bool_t active; /* is the port active _at all_? */ - bool_t active_in; /* is the incoming port in use? */ - bool_t active_out; /* is the outgoing port in use? */ -#endif /* COM_BIDIR */ -#ifdef COM_MULTIPORT - bool_t multiport; /* is this unit part of a multiport device? */ -#endif /* COM_MULTIPORT */ - - /* - * The high level of the driver never reads status registers directly - * because there would be too many side effects to handle conveniently. - * Instead, it reads copies of the registers stored here by the - * interrupt handler. - */ - u_char last_modem_status; /* last MSR read by intr handler */ - u_char prev_modem_status; /* last MSR handled by high level */ - - u_char *ibuf; /* start of input buffer */ - u_char *ibufend; /* end of input buffer */ - u_char *ihighwater; /* threshold in input buffer */ - u_char *iptr; /* next free spot in input buffer */ - - u_char *obufend; /* end of output buffer */ - int ocount; /* original count for current output */ - u_char *optr; /* next char to output */ - - Port_t data_port; /* i/o ports */ - Port_t int_id_port; - Port_t iobase; - Port_t modem_ctl_port; - Port_t line_status_port; - Port_t modem_status_port; - - struct tty *tp; /* cross reference */ - - u_long bytes_in; /* statistics */ - u_long bytes_out; - u_int delta_error_counts[CE_NTYPES]; - u_int error_counts[CE_NTYPES]; - - /* - * Ping-pong input buffers. The extra factor of 2 in the sizes is - * to allow for an error byte for each input byte. - */ -#define CE_INPUT_OFFSET RS_IBUFSIZE - u_char ibuf1[2 * RS_IBUFSIZE]; - u_char ibuf2[2 * RS_IBUFSIZE]; -}; - - -/* - * These functions in the com module ought to be declared (with a prototype) - * in a com-driver system header. The void ones may need to be int to match - * ancient devswitch declarations, but they don't actually return anything. - */ -#define Dev_t int /* promoted dev_t */ -struct consdev; - -int sioclose __P((Dev_t dev, int fflag, int devtype, - struct proc *p)); -void siointr __P((int unit)); -#ifdef COM_MULTIPORT -bool_t comintr1 __P((struct com_s *com)); -#endif /* COM_MULTIPORT */ -int sioioctl __P((Dev_t dev, int cmd, caddr_t data, - int fflag, struct proc *p)); -int siocngetc __P((Dev_t dev)); -void siocninit __P((struct consdev *cp)); -void siocnprobe __P((struct consdev *cp)); -void siocnputc __P((Dev_t dev, int c)); -int sioopen __P((Dev_t dev, int oflags, int devtype, - struct proc *p)); -/* - * sioopen gets compared to the d_open entry in struct cdevsw. d_open and - * other functions are declared in <sys/conf.h> with short types like dev_t - * in the prototype. Such declarations are broken because they vary with - * __P (significantly in theory - the compiler is allowed to push a short - * arg if it has seen the prototype; insignificantly in practice - gcc - * doesn't push short args and it would be slower on 386's to do so). - * - * Also, most of the device switch functions are still declared old-style - * so they take a Dev_t arg and shorten it to a dev_t. It would be simpler - * and faster if dev_t's were always promoted (to ints or whatever) as - * early as possible. - * - * Until <sys/conf.h> is fixed, we cast sioopen to the following `wrong' type - * when comparing it to the d_open entry just to avoid compiler warnings. - */ -typedef int (*bogus_open_t) __P((dev_t dev, int oflags, int devtype, - struct proc *p)); -int sioread __P((Dev_t dev, struct uio *uio, int ioflag)); -void siostop __P((struct tty *tp, int rw)); -int siowrite __P((Dev_t dev, struct uio *uio, int ioflag)); -void softsio0 __P((void)); -void softsio1 __P((void)); -void softsio2 __P((void)); -void softsio3 __P((void)); -void softsio4 __P((void)); -void softsio5 __P((void)); -void softsio6 __P((void)); -void softsio7 __P((void)); -void softsio8 __P((void)); - -static int sioattach __P((struct isa_device *dev)); -static void comflush __P((struct com_s *com)); -static void comhardclose __P((struct com_s *com)); -static void cominit __P((int unit, int rate)); -static int commctl __P((struct com_s *com, int bits, int how)); -static int comparam __P((struct tty *tp, struct termios *t)); -static int sioprobe __P((struct isa_device *dev)); -static void compoll __P((void)); -static int comstart __P((struct tty *tp)); -static void comwakeup __P((void)); - -/* table and macro for fast conversion from a unit number to its com struct */ -static struct com_s *p_com_addr[NSIO]; -#define com_addr(unit) (p_com_addr[unit]) - -static struct com_s com_structs[NSIO]; - -struct isa_driver siodriver = { - sioprobe, sioattach, "sio" -}; - -#ifdef COMCONSOLE -static int comconsole = COMCONSOLE; -#else -static int comconsole = -1; -#endif -static bool_t comconsinit; -static speed_t comdefaultrate = TTYDEF_SPEED; -static u_int com_events; /* input chars + weighted output completions */ -static int commajor; -struct tty sio_tty[NSIO]; -extern struct tty *constty; -extern u_int ipending; /* XXX */ -extern int tk_nin; /* XXX */ -extern int tk_rawcc; /* XXX */ - -#ifdef KGDB -#include "machine/remote-sl.h" - -extern int kgdb_dev; -extern int kgdb_rate; -extern int kgdb_debug_init; -#endif - -static struct speedtab comspeedtab[] = { - 0, 0, - 50, COMBRD(50), - 75, COMBRD(75), - 110, COMBRD(110), - 134, COMBRD(134), - 150, COMBRD(150), - 200, COMBRD(200), - 300, COMBRD(300), - 600, COMBRD(600), - 1200, COMBRD(1200), - 1800, COMBRD(1800), - 2400, COMBRD(2400), - 4800, COMBRD(4800), - 9600, COMBRD(9600), - 19200, COMBRD(19200), - 38400, COMBRD(38400), - 57600, COMBRD(57600), - 115200, COMBRD(115200), - -1, -1 -}; - -/* XXX - configure this list */ -static Port_t likely_com_ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, }; - -static int -sioprobe(dev) - struct isa_device *dev; -{ - static bool_t already_init; - Port_t *com_ptr; - Port_t iobase; - int result; - - if (!already_init) { - /* - * Turn off MCR_IENABLE for all likely serial ports. An unused - * port with its MCR_IENABLE gate open will inhibit interrupts - * from any used port that shares the interrupt vector. - */ - for (com_ptr = likely_com_ports; - com_ptr < &likely_com_ports[sizeof likely_com_ports - / sizeof likely_com_ports[0]]; - ++com_ptr) - outb(*com_ptr + com_mcr, 0); - already_init = TRUE; - } - iobase = dev->id_iobase; - result = 1; - - /* - * We don't want to get actual interrupts, just masked ones. - * Interrupts from this line should already be masked in the ICU, - * but mask them in the processor as well in case there are some - * (misconfigured) shared interrupts. - */ - disable_intr(); - - /* - * Enable output interrupts (only) and check the following: - * o the CFCR, IER and MCR in UART hold the values written to them - * (the values happen to be all distinct - this is good for - * avoiding false positive tests from bus echoes). - * o an output interrupt is generated and its vector is correct. - * o the interrupt goes away when the IIR in the UART is read. - */ - outb(iobase + com_cfcr, CFCR_8BITS); /* ensure IER is addressed */ - outb(iobase + com_mcr, MCR_IENABLE); /* open gate early */ - outb(iobase + com_ier, 0); /* ensure edge on next intr */ - outb(iobase + com_ier, IER_ETXRDY); /* generate interrupt */ - if ( inb(iobase + com_cfcr) != CFCR_8BITS - || inb(iobase + com_ier) != IER_ETXRDY - || inb(iobase + com_mcr) != MCR_IENABLE - || (inb(iobase + com_iir) & IIR_IMASK) != IIR_TXRDY - || isa_irq_pending(dev) - || (inb(iobase + com_iir) & IIR_IMASK) != IIR_NOPEND) - result = 0; - - /* - * Turn off all device interrupts and check that they go off properly. - * Leave MCR_IENABLE set. It gates the OUT2 output of the UART to - * the ICU input. Closing the gate would give a floating ICU input - * (unless there is another device driving at) and spurious interrupts. - * (On the system that this was first tested on, the input floats high - * and gives a (masked) interrupt as soon as the gate is closed.) - */ - outb(iobase + com_ier, 0); - outb(iobase + com_mcr, MCR_IENABLE); /* dummy to avoid bus echo */ - if ( inb(iobase + com_ier) != 0 - || isa_irq_pending(dev) - || (inb(iobase + com_iir) & IIR_IMASK) != IIR_NOPEND) - result = 0; - - enable_intr(); - - return (result); -} - -static int /* XXX - should be void */ -sioattach(isdp) - struct isa_device *isdp; -{ - struct com_s *com; - static bool_t comwakeup_started = FALSE; - Port_t iobase; - int s; - u_char scr; - u_char scr1; - u_char scr2; - int unit; - - iobase = isdp->id_iobase; - unit = isdp->id_unit; - if (unit == comconsole) - DELAY(1000); /* XXX */ - s = spltty(); - - /* - * sioprobe() has initialized the device registers as follows: - * o cfcr = CFCR_8BITS. - * It is most important that CFCR_DLAB is off, so that the - * data port is not hidden when we enable interrupts. - * o ier = 0. - * Interrupts are only enabled when the line is open. - * o mcr = MCR_IENABLE. - * Keeping MCR_DTR and MCR_RTS off might stop the external - * device from sending before we are ready. - */ - - com = &com_structs[unit]; - com->cfcr_image = CFCR_8BITS; - com->mcr_image = MCR_IENABLE; -#if 0 - com->softDCD = TRUE; -#endif - com->iptr = com->ibuf = com->ibuf1; - com->ibufend = com->ibuf1 + RS_IBUFSIZE; - com->ihighwater = com->ibuf1 + RS_IHIGHWATER; - com->iobase = iobase; - com->data_port = iobase + com_data; - com->int_id_port = iobase + com_iir; - com->modem_ctl_port = iobase + com_mcr; - com->line_status_port = iobase + com_lsr; - com->modem_status_port = iobase + com_msr; - com->tp = &sio_tty[unit]; -#ifdef COM_BIDIR - /* - * if bidirectional ports possible, clear the bidir port info; - */ - com->bidir = FALSE; - com->active = FALSE; - com->active_in = com->active_out = FALSE; -#endif /* COM_BIDIR */ - - /* attempt to determine UART type */ - scr = inb(iobase + com_scr); - outb(iobase + com_scr, 0xa5); - scr1 = inb(iobase + com_scr); - outb(iobase + com_scr, 0x5a); - scr2 = inb(iobase + com_scr); - outb(iobase + com_scr, scr); - printf("sio%d: type", unit); - if (scr1 != 0xa5 || scr2 != 0x5a) - printf(" <8250>"); - else { - outb(iobase + com_fifo, FIFO_ENABLE | FIFO_TRIGGER_14); - DELAY(100); - switch (inb(iobase + com_iir) & IIR_FIFO_MASK) { - case FIFO_TRIGGER_1: - printf(" <16450>"); - break; - case FIFO_TRIGGER_4: - printf(" <16450?>"); - break; - case FIFO_TRIGGER_8: - printf(" <16550?>"); - break; - case FIFO_TRIGGER_14: - com->hasfifo = TRUE; - printf(" <16550A>"); - break; - } - outb(iobase + com_fifo, 0); - } - printf("\n"); -#ifdef COM_MULTIPORT - if (COM_ISMULTIPORT(isdp)) { - struct isa_device *masterdev; - - com->multiport = TRUE; - printf(" (multiport)"); - - /* set the master's common-interrupt-enable reg., - * as appropriate. YYY See your manual - */ - /* enable only common interrupt for port */ - outb(iobase + com_mcr, 0); - - masterdev = find_isadev(isa_devtab_tty, &siodriver, - COM_MPMASTER(isdp)); - outb(masterdev->id_iobase+com_scr, 0x80); - } - else - com->multiport = FALSE; -#endif /* COM_MULTIPORT */ - -#ifdef KGDB - if (kgdb_dev == makedev(commajor, unit)) { - if (comconsole == unit) - kgdb_dev = -1; /* can't debug over console port */ - else { - cominit(unit, kgdb_rate); - if (kgdb_debug_init) { - /* - * Print prefix of device name, - * let kgdb_connect print the rest. - */ - printf("com%d: ", unit); - kgdb_connect(1); - } - else - printf("com%d: kgdb enabled\n", unit); - } - } -#endif - - /* - * Need to reset baud rate, etc. of next print so reset comconsinit. - * Also make sure console is always "hardwired" - */ - if (unit == comconsole) { - comconsinit = FALSE; - com->softDCD = TRUE; - } - - com_addr(unit) = com; - - splx(s); - - if (!comwakeup_started) { - comwakeup(); - comwakeup_started = TRUE; - } - - return (1); -} - -/* ARGSUSED */ -int -sioopen(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; -{ - struct com_s *com; - int error = 0; - Port_t iobase; - int s; - struct tty *tp; - int unit = UNIT(dev); -#ifdef COM_BIDIR - bool_t callout = CALLOUT(dev); -#endif /* COM_BIDIR */ - if ((u_int) unit >= NSIO || (com = com_addr(unit)) == NULL) - return (ENXIO); -#ifdef COM_BIDIR - /* if it's a callout device, and bidir not possible on that dev, die */ - if (callout && !(com->bidir)) - return (ENXIO); -#endif /* COM_BIDIR */ - - tp = com->tp; - s = spltty(); - -#ifdef COM_BIDIR - -bidir_open_top: - /* if it's bidirectional, we've gotta deal with it... */ - if (com->bidir) { - if (callout) { - if (com->active_in) { - /* it's busy. die */ - splx(s); - return (EBUSY); - } else { - /* it's ours. lock it down, and set it up */ - com->active_out = TRUE; - com->softDCD = TRUE; - } - } else { - if (com->active_out) { - /* it's busy, outgoing. wait, if possible */ - if (flag & O_NONBLOCK) { - /* can't wait; bail */ - splx(s); - return (EBUSY); - } else { - /* wait for it... */ - error = tsleep(&com->active_out, - TTIPRI|PCATCH, - "comoth", - 0); - /* if there was an error, take off. */ - if (error != 0) { - splx(s); - return (error); - } - /* else take it from the top */ - goto bidir_open_top; - } - } else if (com->last_modem_status & MSR_DCD) { - /* there's a carrier on the line; we win */ - com->active_in = TRUE; - com->softDCD = FALSE; - } else { - /* there is no carrier on the line */ - if (flag & O_NONBLOCK) { - /* can't wait; let it open */ - com->active_in = TRUE; - com->softDCD = FALSE; - } else { - /* put DTR & RTS up */ - /* NOTE: cgd'sdriver used the ier register - * to enable/disable interrupts. This one - * uses both ier and IENABLE in the mcr. - */ - (void) commctl(com, MCR_DTR | MCR_RTS, DMSET); - outb(com->iobase + com_ier, IER_EMSC); - /* wait for it... */ - error = tsleep(&com->active_in, - TTIPRI|PCATCH, - "comdcd", - 0); - - /* if not active, turn DTR & RTS off */ - if (!com->active) - (void) commctl(com, MCR_DTR | MCR_RTS, DMBIC); - - /* if there was an error, take off. */ - if (error != 0) { - splx(s); - return (error); - } - /* else take it from the top */ - goto bidir_open_top; - } - } - } - } - - com->active = TRUE; -#endif /* COM_BIDIR */ - - tp->t_oproc = comstart; - tp->t_param = comparam; - tp->t_dev = dev; - if (!(tp->t_state & TS_ISOPEN)) { - tp->t_state |= TS_WOPEN; - ttychars(tp); - if (tp->t_ispeed == 0) { - /* - * We no longer use the flags from <sys/ttydefaults.h> - * since those are only relevant for logins. It's - * important to have echo off initially so that the - * line doesn't start blathering before the echo flag - * can be turned off. - */ - tp->t_iflag = 0; - tp->t_oflag = 0; - tp->t_cflag = CREAD | CS8 | HUPCL; - tp->t_lflag = 0; - tp->t_ispeed = tp->t_ospeed = comdefaultrate; - } - (void) commctl(com, MCR_DTR | MCR_RTS, DMSET); - error = comparam(tp, &tp->t_termios); - if (error != 0) - goto out; - ttsetwater(tp); - iobase = com->iobase; - disable_intr(); - if (com->hasfifo) - /* (re)enable and drain FIFO */ - outb(iobase + com_fifo, FIFO_ENABLE | FIFO_TRIGGER_14 - | FIFO_RCV_RST | FIFO_XMT_RST); - (void) inb(com->line_status_port); - (void) inb(com->data_port); - com->last_modem_status = - com->prev_modem_status = inb(com->modem_status_port); - outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS - | IER_EMSC); - enable_intr(); - if (com->softDCD || com->prev_modem_status & MSR_DCD) - tp->t_state |= TS_CARR_ON; - } - else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) { - splx(s); - return (EBUSY); - } - while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) -#ifdef COM_BIDIR - /* We went through a lot of trouble to open it, - * but it's certain we have a carrier now, so - * don't spend any time on it now. - */ - && !(com->bidir) -#endif /* COM_BIDIR */ - && !(tp->t_state & TS_CARR_ON)) { - tp->t_state |= TS_WOPEN; - error = ttysleep(tp, (caddr_t)&tp->t_raw, TTIPRI | PCATCH, - ttopen, 0); - if (error != 0) - break; - } -out: - splx(s); - if (error == 0) - error = (*linesw[tp->t_line].l_open)(dev, tp); - -#ifdef COM_BIDIR - /* wakeup sleepers */ - wakeup((caddr_t) &com->active_in); -#endif /* COM_BIDIR */ - - /* - * XXX - the next step was once not done, so interrupts, DTR and RTS - * remainded hot if the process was killed while it was sleeping - * waiting for carrier. Now there is the opposite problem. If several - * processes are sleeping waiting for carrier on the same line and one - * is killed, interrupts are turned off so the other processes will - * never see the carrier rise. - */ - if (error != 0 && !(tp->t_state & TS_ISOPEN)) -{ - comhardclose(com); -} - tp->t_state &= ~TS_WOPEN; - - return (error); -} - -/*ARGSUSED*/ -int -sioclose(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; -{ - struct com_s *com; - struct tty *tp; - - com = com_addr(UNIT(dev)); - tp = com->tp; - (*linesw[tp->t_line].l_close)(tp, flag); - comhardclose(com); - ttyclose(tp); - return (0); -} - -void -comhardclose(com) - struct com_s *com; -{ - Port_t iobase; - int s; - struct tty *tp; - - s = spltty(); - iobase = com->iobase; - outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK); -#ifdef KGDB - /* do not disable interrupts if debugging */ - if (kgdb_dev != makedev(commajor, com - &com_structs[0])) -#endif - outb(iobase + com_ier, 0); - tp = com->tp; - if (tp->t_cflag & HUPCL || tp->t_state & TS_WOPEN - || !(tp->t_state & TS_ISOPEN)) - (void) commctl(com, 0, DMSET); -#ifdef COM_BIDIR - com->active = com->active_in = com->active_out = FALSE; - com->softDCD = FALSE; - - /* wakeup sleepers who are waiting for out to finish */ - wakeup((caddr_t) &com->active_out); -#endif /* COM_BIDIR */ - - splx(s); -} - -int -sioread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = com_addr(UNIT(dev))->tp; - - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -int -siowrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int unit = UNIT(dev); - struct tty *tp = com_addr(unit)->tp; - - /* - * (XXX) We disallow virtual consoles if the physical console is - * a serial port. This is in case there is a display attached that - * is not the console. In that situation we don't need/want the X - * server taking over the console. - */ - if (constty && unit == comconsole) - constty = NULL; - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - -void -siointr(unit) - int unit; -{ - struct com_s *com; -#ifndef COM_MULTIPORT - u_char line_status; - u_char modem_status; - u_char *ioptr; - u_char recv_data; - - com = com_addr(unit); -#else /* COM_MULTIPORT */ - int i; - bool_t donesomething; - - do { - donesomething = FALSE; - for(i=0;i<NSIO;i++) { - com=com_addr(i); - if(com != NULL) { - /* XXX When siointr is called - * to start output, maybe - * it should be changed to a - * call to comintr1. Doesn't - * seem a good idea: interrupts - * are disabled all the time. - */ -enable_intr(); -disable_intr(); - donesomething = comintr1(com); - } - } - } while (donesomething); - return; -} - -bool_t -comintr1(struct com_s *com) -{ - u_char line_status; - u_char modem_status; - u_char *ioptr; - u_char recv_data; - bool_t donesomething; - - donesomething = FALSE; -#endif /* COM_MULTIPORT */ - - while (TRUE) { - line_status = inb(com->line_status_port); - - /* input event? (check first to help avoid overruns) */ - while (line_status & LSR_RCV_MASK) { - /* break/unnattached error bits or real input? */ -#ifdef COM_MULTIPORT - donesomething = TRUE; -#endif /* COM_MULTIPORT */ - if (!(line_status & LSR_RXRDY)) - recv_data = 0; - else - recv_data = inb(com->data_port); - ++com->bytes_in; -#ifdef KGDB - /* trap into kgdb? (XXX - needs testing and optim) */ - if (recv_data == FRAME_END - && !(com->tp->t_state & TS_ISOPEN) - && kgdb_dev == makedev(commajor, unit)) { - kgdb_connect(0); - continue; - } -#endif /* KGDB */ - ioptr = com->iptr; - if (ioptr >= com->ibufend) - CE_RECORD(com, CE_INTERRUPT_BUF_OVERFLOW); - else { - ++com_events; - ioptr[0] = recv_data; - ioptr[CE_INPUT_OFFSET] = line_status; - com->iptr = ++ioptr; - if (ioptr == com->ihighwater - && com->state & CS_RTS_IFLOW) - outb(com->modem_ctl_port, - com->mcr_image &= ~MCR_RTS); - } - - /* - * "& 0x7F" is to avoid the gcc-1.40 generating a slow - * jump from the top of the loop to here - */ - line_status = inb(com->line_status_port) & 0x7F; - } - - /* modem status change? (always check before doing output) */ - modem_status = inb(com->modem_status_port); - if (modem_status != com->last_modem_status) { - /* - * Schedule high level to handle DCD changes. Note - * that we don't use the delta bits anywhere. Some - * UARTs mess them up, and it's easy to remember the - * previous bits and calculate the delta. - */ -#ifdef COM_MULTIPORT - donesomething = TRUE; -#endif /* COM_MULTIPORT */ - com->last_modem_status = modem_status; - if (!(com->state & CS_CHECKMSR)) { - com_events += LOTS_OF_EVENTS; - com->state |= CS_CHECKMSR; - schedsoftcom(); - } - - /* handle CTS change immediately for crisp flow ctl */ - if (com->state & CS_CTS_OFLOW) { - if (modem_status & MSR_CTS) - com->state |= CS_ODEVREADY; - else - com->state &= ~CS_ODEVREADY; - } - } - - /* output queued and everything ready? */ - if (line_status & LSR_TXRDY - && com->state >= (CS_ODEVREADY | CS_BUSY | CS_TTGO)) { -#ifdef COM_MULTIPORT - donesomething = TRUE; -#endif /* COM_MULTIPORT */ - ioptr = com->optr; - outb(com->data_port, *ioptr); - ++com->bytes_out; - com->optr = ++ioptr; - if (ioptr >= com->obufend) { - /* output just completed */ - com_events += LOTS_OF_EVENTS; - com->state ^= (CS_ODONE | CS_BUSY); - schedsoftcom(); /* handle at high level ASAP */ - } - } - - /* finished? */ - if ((inb(com->int_id_port) & IIR_IMASK) == IIR_NOPEND) -#ifdef COM_MULTIPORT - return (donesomething); -#else - return; -#endif /* COM_MULTIPORT */ - } -} - -int -sioioctl(dev, cmd, data, flag, p) - dev_t dev; - int cmd; - caddr_t data; - int flag; - struct proc *p; -{ - struct com_s *com; - int error; - Port_t iobase; - int s; - struct tty *tp; - - com = com_addr(UNIT(dev)); - tp = com->tp; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag); - if (error >= 0) - return (error); - error = ttioctl(tp, cmd, data, flag); - if (error >= 0) - return (error); - - iobase = com->iobase; - s = spltty(); - switch (cmd) { - case TIOCSBRK: - outb(iobase + com_cfcr, com->cfcr_image |= CFCR_SBREAK); - break; - case TIOCCBRK: - outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK); - break; - case TIOCSDTR: - (void) commctl(com, MCR_DTR | MCR_RTS, DMBIS); - break; - case TIOCCDTR: - (void) commctl(com, MCR_DTR | MCR_RTS, DMBIC); - break; - case TIOCMSET: - (void) commctl(com, *(int *)data, DMSET); - break; - case TIOCMBIS: - (void) commctl(com, *(int *)data, DMBIS); - break; - case TIOCMBIC: - (void) commctl(com, *(int *)data, DMBIC); - break; - case TIOCMGET: - *(int *)data = commctl(com, 0, DMGET); - break; -#ifdef COM_BIDIR - case TIOCMSBIDIR: - /* must be root to set bidir. capability */ - if (p->p_ucred->cr_uid != 0) - return(EPERM); - - /* if it's the console, can't do it */ - if (UNIT(dev) == comconsole) - return(ENOTTY); - - /* can't do the next, for obvious reasons... - * but there are problems to be looked at... - */ - - /* if the port is active, don't do it */ - /* if (com->active) - return(EBUSY); */ - - com->bidir = *(int *)data; - break; - case TIOCMGBIDIR: - *(int *)data = com->bidir; - break; -#endif /* COM_BIDIR */ - default: - splx(s); - return (ENOTTY); - } - splx(s); - return (0); -} - -/* cancel pending output */ -static void -comflush(com) - struct com_s *com; -{ - struct ringb *rbp; - - disable_intr(); - if (com->state & CS_ODONE) - com_events -= LOTS_OF_EVENTS; - com->state &= ~(CS_ODONE | CS_BUSY); - enable_intr(); - rbp = &com->tp->t_out; - rbp->rb_hd += com->ocount; - rbp->rb_hd = RB_ROLLOVER(rbp, rbp->rb_hd); - com->ocount = 0; - com->tp->t_state &= ~TS_BUSY; -} - -static void -compoll() -{ - static bool_t awake = FALSE; - struct com_s *com; - int s; - int unit; - - if (com_events == 0) - return; - disable_intr(); - if (awake) { - enable_intr(); - return; - } - awake = TRUE; - enable_intr(); - s = spltty(); -repeat: - for (unit = 0; unit < NSIO; ++unit) { - u_char *buf; - u_char *ibuf; - int incc; - struct tty *tp; - - com = com_addr(unit); - if (com == NULL) - continue; - tp = com->tp; - - /* switch the role of the low-level input buffers */ - if (com->iptr == (ibuf = com->ibuf)) - incc = 0; - else { - buf = ibuf; - disable_intr(); - incc = com->iptr - buf; - com_events -= incc; - if (ibuf == com->ibuf1) - ibuf = com->ibuf2; - else - ibuf = com->ibuf1; - com->ibufend = ibuf + RS_IBUFSIZE; - com->ihighwater = ibuf + RS_IHIGHWATER; - com->iptr = ibuf; - - /* - * There is now room for another low-level buffer full - * of input, so enable RTS if it is now disabled and - * there is room in the high-level buffer. - */ - if (!(com->mcr_image & MCR_RTS) - && !(tp->t_state & TS_RTSBLOCK)) - outb(com->modem_ctl_port, - com->mcr_image |= MCR_RTS); - enable_intr(); - com->ibuf = ibuf; - } - - if (com->state & CS_CHECKMSR) { - u_char delta_modem_status; - - disable_intr(); - delta_modem_status = com->last_modem_status - ^ com->prev_modem_status; - com->prev_modem_status = com->last_modem_status; - com_events -= LOTS_OF_EVENTS; - com->state &= ~CS_CHECKMSR; - enable_intr(); - if (delta_modem_status & MSR_DCD && - unit != comconsole) { -#ifdef COM_BIDIR - if (com->prev_modem_status & MSR_DCD) { - (*linesw[tp->t_line].l_modem)(tp, 1); - com->softDCD = FALSE; - wakeup((caddr_t) &com->active_in); - } -#else - if (com->prev_modem_status & MSR_DCD) - (*linesw[tp->t_line].l_modem)(tp, 1); -#endif /* COM_BIDIR */ - else if ((*linesw[tp->t_line].l_modem)(tp, 0) - == 0) { - disable_intr(); - outb(com->modem_ctl_port, - com->mcr_image - &= ~(MCR_DTR | MCR_RTS)); - enable_intr(); - } - } - } - - /* XXX */ - if (TRUE) { - u_int delta; - u_int delta_error_counts[CE_NTYPES]; - int errnum; - u_long total; - - disable_intr(); - bcopy(com->delta_error_counts, delta_error_counts, - sizeof delta_error_counts); - bzero(com->delta_error_counts, - sizeof delta_error_counts); - enable_intr(); - for (errnum = 0; errnum < CE_NTYPES; ++errnum) { - delta = delta_error_counts[errnum]; - if (delta != 0) { - total = - com->error_counts[errnum] += delta; - log(LOG_WARNING, - "com%d: %u more %s%s (total %lu)\n", - unit, delta, error_desc[errnum], - delta == 1 ? "" : "s", total); - } - } - } - if (com->state & CS_ODONE) { - comflush(com); - /* XXX - why isn't the table used for t_line == 0? */ - if (tp->t_line != 0) - (*linesw[tp->t_line].l_start)(tp); - else - comstart(tp); - } - if (incc <= 0 || !(tp->t_state & TS_ISOPEN)) - continue; - if (com->state & CS_RTS_IFLOW - && RB_LEN(&tp->t_raw) + incc >= RB_I_HIGH_WATER - && !(tp->t_state & TS_RTSBLOCK) - /* - * XXX - need RTS flow control for all line disciplines. - * Only have it in standard one now. - */ - && linesw[tp->t_line].l_rint == ttyinput) { - tp->t_state |= TS_RTSBLOCK; - ttstart(tp); - } - /* - * Avoid the grotesquely inefficient lineswitch routine - * (ttyinput) in "raw" mode. It usually takes about 450 - * instructions (that's without canonical processing or echo!). - * slinput is reasonably fast (usually 40 instructions plus - * call overhead). - */ - if (!(tp->t_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP - | IXOFF | IXON)) - && !(tp->t_lflag & (ECHO | ECHONL | ICANON | IEXTEN | ISIG - | PENDIN)) - && !(tp->t_state & (TS_CNTTB | TS_LNCH)) - && linesw[tp->t_line].l_rint == ttyinput) { - tk_nin += incc; - tk_rawcc += incc; - tp->t_rawcc += incc; - com->delta_error_counts[CE_TTY_BUF_OVERFLOW] - += incc - rb_write(&tp->t_raw, (char *) buf, - incc); - ttwakeup(tp); - if (tp->t_state & TS_TTSTOP - && (tp->t_iflag & IXANY - || tp->t_cc[VSTART] == tp->t_cc[VSTOP])) { - tp->t_state &= ~TS_TTSTOP; - tp->t_lflag &= ~FLUSHO; - ttstart(tp); - } - } - else { - do { - u_char line_status; - int recv_data; - - line_status = (u_char) buf[CE_INPUT_OFFSET]; - recv_data = (u_char) *buf++; - if (line_status - & (LSR_BI | LSR_FE | LSR_OE | LSR_PE)) { - if (line_status & LSR_BI) - recv_data |= TTY_BI; - if (line_status & LSR_FE) - recv_data |= TTY_FE; - if (line_status & LSR_OE) - recv_data |= TTY_OE; - if (line_status & LSR_PE) - recv_data |= TTY_PE; - } - (*linesw[tp->t_line].l_rint)(recv_data, tp); - } while (--incc > 0); - } - if (com_events == 0) - break; - } - if (com_events >= LOTS_OF_EVENTS) - goto repeat; - splx(s); - awake = FALSE; -} - -static int -comparam(tp, t) - struct tty *tp; - struct termios *t; -{ - u_int cfcr; - int cflag; - struct com_s *com; - int divisor; - int error; - Port_t iobase; - int s; - int unit; - - /* check requested parameters */ - divisor = ttspeedtab(t->c_ospeed, comspeedtab); - if (divisor < 0 || t->c_ispeed != 0 && t->c_ispeed != t->c_ospeed) - return (EINVAL); - - /* parameters are OK, convert them to the com struct and the device */ - unit = UNIT(tp->t_dev); - com = com_addr(unit); - iobase = com->iobase; - s = spltty(); - if (divisor == 0) { - (void) commctl(com, 0, DMSET); /* hang up line */ - splx(s); - return (0); - } - cflag = t->c_cflag; - switch (cflag & CSIZE) { - case CS5: - cfcr = CFCR_5BITS; - break; - case CS6: - cfcr = CFCR_6BITS; - break; - case CS7: - cfcr = CFCR_7BITS; - break; - default: - cfcr = CFCR_8BITS; - break; - } - if (cflag & PARENB) { - cfcr |= CFCR_PENAB; - if (!(cflag & PARODD)) - cfcr |= CFCR_PEVEN; - } - if (cflag & CSTOPB) - cfcr |= CFCR_STOPB; - - /* - * Some UARTs lock up if the divisor latch registers are selected - * while the UART is doing output (they refuse to transmit anything - * more until given a hard reset). Fix this by stopping filling - * the device buffers and waiting for them to drain. Reading the - * line status port outside of siointr() might lose some receiver - * error bits, but that is acceptable here. - */ - disable_intr(); - com->state &= ~CS_TTGO; - enable_intr(); - while ((inb(com->line_status_port) & (LSR_TSRE | LSR_TXRDY)) - != (LSR_TSRE | LSR_TXRDY)) { - error = ttysleep(tp, (caddr_t)&tp->t_raw, TTIPRI | PCATCH, - "comparam", 1); - if (error != 0 && error != EAGAIN) { - if (!(tp->t_state & TS_TTSTOP)) { - disable_intr(); - com->state |= CS_TTGO; - enable_intr(); - } - splx(s); - return (error); - } - } - - disable_intr(); /* very important while com_data is hidden */ - outb(iobase + com_cfcr, cfcr | CFCR_DLAB); - outb(iobase + com_dlbl, divisor & 0xFF); - outb(iobase + com_dlbh, (u_int) divisor >> 8); - outb(iobase + com_cfcr, com->cfcr_image = cfcr); - if (!(tp->t_state & TS_TTSTOP)) - com->state |= CS_TTGO; - if (cflag & CRTS_IFLOW) - com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */ - else - com->state &= ~CS_RTS_IFLOW; - - /* - * Set up state to handle output flow control. - * XXX - worth handling MDMBUF (DCD) flow control at the lowest level? - * Now has 16+ msec latency, while CTS flow has 50- usec latency. - * Note that DCD flow control stupidly uses the same state flag - * (TS_TTSTOP) as XON/XOFF flow control. - */ - com->state &= ~CS_CTS_OFLOW; - com->state |= CS_ODEVREADY; - if (cflag & CCTS_OFLOW) { - com->state |= CS_CTS_OFLOW; - if (!(com->prev_modem_status & MSR_CTS)) - com->state &= ~CS_ODEVREADY; - } - - enable_intr(); - siointr(unit); /* recover from fiddling with CS_TTGO */ - splx(s); - return (0); -} - -static int /* XXX - should be void */ -comstart(tp) - struct tty *tp; -{ - struct com_s *com; - int s; - int unit; - - unit = UNIT(tp->t_dev); - com = com_addr(unit); - s = spltty(); - disable_intr(); - if (tp->t_state & TS_TTSTOP) - com->state &= ~CS_TTGO; - else - com->state |= CS_TTGO; - if (tp->t_state & TS_RTSBLOCK) { - if (com->mcr_image & MCR_RTS && com->state & CS_RTS_IFLOW) - outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS); - } - else { - if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater) - outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS); - } - enable_intr(); - if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) - goto out; - if (RB_LEN(&tp->t_out) <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_out); - } - if (tp->t_wsel) { - selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL); - tp->t_wsel = 0; - tp->t_state &= ~TS_WCOLL; - } - } - if (com->ocount != 0) { - disable_intr(); - siointr(unit); - enable_intr(); - } - else if (RB_LEN(&tp->t_out) != 0) { - tp->t_state |= TS_BUSY; - com->ocount = RB_CONTIGGET(&tp->t_out); - disable_intr(); - com->obufend = (com->optr = (u_char *) tp->t_out.rb_hd) - + com->ocount; - com->state |= CS_BUSY; - siointr(unit); /* fake interrupt to start output */ - enable_intr(); - } -out: - splx(s); - return (1); -} - -void -siostop(tp, rw) - struct tty *tp; - int rw; -{ - struct com_s *com; - - com = com_addr(UNIT(tp->t_dev)); - if (rw & FWRITE) - comflush(com); - disable_intr(); - if (tp->t_state & TS_TTSTOP) - com->state &= ~CS_TTGO; - else - com->state |= CS_TTGO; - enable_intr(); -} - -static int -commctl(com, bits, how) - struct com_s *com; - int bits; - int how; -{ - disable_intr(); - switch (how) { - case DMSET: -#ifdef COM_MULTIPORT - /* YYY maybe your card doesn't want IENABLE to be reset? */ - if(com->multiport) - outb(com->modem_ctl_port, - com->mcr_image = bits); - else -#endif /* COM_MULTIPORT */ - outb(com->modem_ctl_port, - com->mcr_image = bits | MCR_IENABLE); - break; - case DMBIS: - outb(com->modem_ctl_port, com->mcr_image |= bits); - break; - case DMBIC: -#ifdef COM_MULTIPORT - /* YYY maybe your card doesn't want IENABLE to be reset? */ - if(com->multiport) - outb(com->modem_ctl_port, - com->mcr_image &= ~(bits)); - else -#endif /* COM_MULTIPORT */ - outb(com->modem_ctl_port, - com->mcr_image &= ~(bits & ~MCR_IENABLE)); - break; - case DMGET: - bits = com->prev_modem_status; - break; - } - enable_intr(); - return (bits); -} - -static void -comwakeup() -{ - struct com_s *com; - int unit; - - timeout((timeout_func_t) comwakeup, (caddr_t) NULL, 1); - if (com_events != 0) - /* schedule compoll() to run when the cpl allows */ - schedsoftcom(); - - /* recover from lost output interrupts */ - for (unit = 0; unit < NSIO; ++unit) { - com = com_addr(unit); - if (com != NULL && com->state >= (CS_BUSY | CS_TTGO)) { - disable_intr(); - siointr(unit); - enable_intr(); - } - } -} - -void -softsio0() { compoll(); } - -void -softsio1() { compoll(); } - -void -softsio2() { compoll(); } - -void -softsio3() { compoll(); } - -void -softsio4() { compoll(); } - -void -softsio5() { compoll(); } - -void -softsio6() { compoll(); } - -void -softsio7() { compoll(); } - -void -softsio8() { compoll(); } - -/* - * Following are all routines needed for COM to act as console - * XXX - not tested in this version - * XXX - check that the corresponding serial interrupts are never enabled - */ -#include "i386/i386/cons.h" - -void -siocnprobe(cp) - struct consdev *cp; -{ - int unit; - - /* locate the major number */ - for (commajor = 0; commajor < nchrdev; commajor++) - if (cdevsw[commajor].d_open == (bogus_open_t) sioopen) - break; - - /* XXX: ick */ - unit = CONUNIT; - com_addr(unit) = &com_structs[unit]; - com_addr(unit)->iobase = CONADDR; - - /* make sure hardware exists? XXX */ - - /* initialize required fields */ - cp->cn_dev = makedev(commajor, unit); - cp->cn_tp = &sio_tty[unit]; -#ifdef COMCONSOLE - cp->cn_pri = CN_REMOTE; /* Force a serial port console */ -#else - cp->cn_pri = CN_NORMAL; -#endif -} - -void -siocninit(cp) - struct consdev *cp; -{ - int unit; - - unit = UNIT(cp->cn_dev); - cominit(unit, comdefaultrate); - comconsole = unit; - comconsinit = TRUE; -} - -static void -cominit(unit, rate) - int unit; - int rate; -{ - Port_t iobase; - int s; - - iobase = com_addr(unit)->iobase; - s = splhigh(); - outb(iobase + com_cfcr, CFCR_DLAB); - rate = ttspeedtab(comdefaultrate, comspeedtab); - outb(iobase + com_data, rate & 0xFF); - outb(iobase + com_ier, rate >> 8); - outb(iobase + com_cfcr, CFCR_8BITS); - - /* - * XXX - fishy to enable interrupts and then poll. - * It shouldn't be necessary to ready the iir. - */ - outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC); - outb(iobase + com_fifo, - FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); - (void) inb(iobase + com_iir); - splx(s); -} - -int -siocngetc(dev) - dev_t dev; -{ - int c; - Port_t iobase; - int s; - - iobase = com_addr(UNIT(dev))->iobase; - s = splhigh(); - while (!(inb(iobase + com_lsr) & LSR_RXRDY)) - ; - c = inb(iobase + com_data); - (void) inb(iobase + com_iir); - splx(s); - return (c); -} - -void -siocnputc(dev, c) - dev_t dev; - int c; -{ - Port_t iobase; - int s; - int timo; - - iobase = com_addr(UNIT(dev))->iobase; - s = splhigh(); -#ifdef KGDB - if (dev != kgdb_dev) -#endif - if (!comconsinit) { - (void) cominit(UNIT(dev), comdefaultrate); - comconsinit = TRUE; - } - /* wait for any pending transmission to finish */ - timo = 50000; - while (!(inb(iobase + com_lsr) & LSR_TXRDY) && --timo) - ; - outb(iobase + com_data, c); - /* wait for this transmission to complete */ - timo = 1500000; - while (!(inb(iobase + com_lsr) & LSR_TXRDY) && --timo) - ; - /* clear any interrupts generated by this transmission */ - (void) inb(iobase + com_iir); - splx(s); -} - -/* - * 10 Feb 93 Jordan K. Hubbard Added select code - * 27 May 93 Rodney W. Grimes Stole the select code from com.c.pl5 - */ - -int -sioselect(dev, rw, p) - dev_t dev; - int rw; - struct proc *p; -{ - register struct tty *tp = &sio_tty[UNIT(dev)]; - int nread; - int s = spltty(); - struct proc *selp; - - switch (rw) { - - case FREAD: - nread = ttnread(tp); - if (nread > 0 || - ((tp->t_cflag&CLOCAL) == 0 && (tp->t_state&TS_CARR_ON) == 0)) - goto win; - if (tp->t_rsel && (selp = pfind(tp->t_rsel)) && selp->p_wchan == (caddr_t)&selwait) - tp->t_state |= TS_RCOLL; - else - tp->t_rsel = p->p_pid; - break; - - case FWRITE: - if (RB_LEN(&tp->t_out) <= tp->t_lowat) - goto win; - if (tp->t_wsel && (selp = pfind(tp->t_wsel)) && selp->p_wchan == (caddr_t)&selwait) - tp->t_state |= TS_WCOLL; - else - tp->t_wsel = p->p_pid; - break; - } - splx(s); - return (0); - win: - splx(s); - return (1); -} - -#endif /* NSIO > 0 */ diff --git a/sys/dev/sio/sioreg.h b/sys/dev/sio/sioreg.h deleted file mode 100644 index 2a62683..0000000 --- a/sys/dev/sio/sioreg.h +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)comreg.h 7.2 (Berkeley) 5/9/91 - */ - - -/* 16 bit baud rate divisor (lower byte in dca_data, upper in dca_ier) */ -#define COMBRD(x) (1843200 / (16*(x))) - -/* interrupt enable register */ -#define IER_ERXRDY 0x1 -#define IER_ETXRDY 0x2 -#define IER_ERLS 0x4 -#define IER_EMSC 0x8 - -/* interrupt identification register */ -#define IIR_IMASK 0xf -#define IIR_RXTOUT 0xc -#define IIR_RLS 0x6 -#define IIR_RXRDY 0x4 -#define IIR_TXRDY 0x2 -#define IIR_NOPEND 0x1 -#define IIR_MLSC 0x0 -#define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */ - -/* fifo control register */ -#define FIFO_ENABLE 0x01 -#define FIFO_RCV_RST 0x02 -#define FIFO_XMT_RST 0x04 -#define FIFO_DMA_MODE 0x08 -#define FIFO_TRIGGER_1 0x00 -#define FIFO_TRIGGER_4 0x40 -#define FIFO_TRIGGER_8 0x80 -#define FIFO_TRIGGER_14 0xc0 - -/* character format control register */ -#define CFCR_DLAB 0x80 -#define CFCR_SBREAK 0x40 -#define CFCR_PZERO 0x30 -#define CFCR_PONE 0x20 -#define CFCR_PEVEN 0x10 -#define CFCR_PODD 0x00 -#define CFCR_PENAB 0x08 -#define CFCR_STOPB 0x04 -#define CFCR_8BITS 0x03 -#define CFCR_7BITS 0x02 -#define CFCR_6BITS 0x01 -#define CFCR_5BITS 0x00 - -/* modem control register */ -#define MCR_LOOPBACK 0x10 -#define MCR_IENABLE 0x08 -#define MCR_DRS 0x04 -#define MCR_RTS 0x02 -#define MCR_DTR 0x01 - -/* line status register */ -#define LSR_RCV_FIFO 0x80 -#define LSR_TSRE 0x40 -#define LSR_TXRDY 0x20 -#define LSR_BI 0x10 -#define LSR_FE 0x08 -#define LSR_PE 0x04 -#define LSR_OE 0x02 -#define LSR_RXRDY 0x01 -#define LSR_RCV_MASK 0x1f - -/* modem status register */ -#define MSR_DCD 0x80 -#define MSR_RI 0x40 -#define MSR_DSR 0x20 -#define MSR_CTS 0x10 -#define MSR_DDCD 0x08 -#define MSR_TERI 0x04 -#define MSR_DDSR 0x02 -#define MSR_DCTS 0x01 - -/* - * WARNING: Serial console is assumed to be at COM1 address - * and CONUNIT must be 0. - */ -#define CONADDR (0x3f8) -#define CONUNIT (0) diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c deleted file mode 100644 index 04feb2f..0000000 --- a/sys/dev/speaker/spkr.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * spkr.c -- device driver for console speaker on 80386 - * - * v1.1 by Eric S. Raymond (esr@snark.thyrsus.com) Feb 1990 - * modified for 386bsd by Andrew A. Chernov <ache@astral.msk.su> - * 386bsd only clean version, all SYSV stuff removed - * use hz value from param.c - */ - -#include "speaker.h" - -#if NSPEAKER > 0 - -#include "param.h" -#include "systm.h" -#include "kernel.h" -#include "errno.h" -#include "buf.h" -#include "uio.h" -#include "spkr.h" - -/**************** MACHINE DEPENDENT PART STARTS HERE ************************* - * - * This section defines a function tone() which causes a tone of given - * frequency and duration from the 80x86's console speaker. - * Another function endtone() is defined to force sound off, and there is - * also a rest() entry point to do pauses. - * - * Audible sound is generated using the Programmable Interval Timer (PIT) and - * Programmable Peripheral Interface (PPI) attached to the 80x86's speaker. The - * PPI controls whether sound is passed through at all; the PIT's channel 2 is - * used to generate clicks (a square wave) of whatever frequency is desired. - */ - -/* - * PIT and PPI port addresses and control values - * - * Most of the magic is hidden in the TIMER_PREP value, which selects PIT - * channel 2, frequency LSB first, square-wave mode and binary encoding. - * The encoding is as follows: - * - * +----------+----------+---------------+-----+ - * | 1 0 | 1 1 | 0 1 1 | 0 | - * | SC1 SC0 | RW1 RW0 | M2 M1 M0 | BCD | - * +----------+----------+---------------+-----+ - * Counter Write Mode 3 Binary - * Channel 2 LSB first, (Square Wave) Encoding - * MSB second - */ -#define PPI 0x61 /* port of Programmable Peripheral Interface */ -#define PPI_SPKR 0x03 /* turn these PPI bits on to pass sound */ -#define PIT_CTRL 0x43 /* PIT control address */ -#define PIT_COUNT 0x42 /* PIT count address */ -#define PIT_MODE 0xB6 /* set timer mode for sound generation */ - -/* - * Magic numbers for timer control. - */ -#define TIMER_CLK 1193180L /* corresponds to 18.2 MHz tick rate */ - -static int endtone() -/* turn off the speaker, ending current tone */ -{ - wakeup((caddr_t)endtone); - outb(PPI, inb(PPI) & ~PPI_SPKR); -} - -static void tone(hz, ticks) -/* emit tone of frequency hz for given number of ticks */ -unsigned int hz, ticks; -{ - unsigned int divisor = TIMER_CLK / hz; - int sps; - -#ifdef DEBUG - printf("tone: hz=%d ticks=%d\n", hz, ticks); -#endif /* DEBUG */ - - /* set timer to generate clicks at given frequency in Hertz */ - sps = spltty(); - outb(PIT_CTRL, PIT_MODE); /* prepare timer */ - outb(PIT_COUNT, (unsigned char) divisor); /* send lo byte */ - outb(PIT_COUNT, (divisor >> 8)); /* send hi byte */ - splx(sps); - - /* turn the speaker on */ - outb(PPI, inb(PPI) | PPI_SPKR); - - /* - * Set timeout to endtone function, then give up the timeslice. - * This is so other processes can execute while the tone is being - * emitted. - */ - timeout((caddr_t)endtone, (caddr_t)NULL, ticks); - sleep((caddr_t)endtone, PZERO - 1); -} - -static int endrest() -/* end a rest */ -{ - wakeup((caddr_t)endrest); -} - -static void rest(ticks) -/* rest for given number of ticks */ -int ticks; -{ - /* - * Set timeout to endrest function, then give up the timeslice. - * This is so other processes can execute while the rest is being - * waited out. - */ -#ifdef DEBUG - printf("rest: %d\n", ticks); -#endif /* DEBUG */ - timeout((caddr_t)endrest, (caddr_t)NULL, ticks); - sleep((caddr_t)endrest, PZERO - 1); -} - -/**************** PLAY STRING INTERPRETER BEGINS HERE ********************** - * - * Play string interpretation is modelled on IBM BASIC 2.0's PLAY statement; - * M[LNS] are missing and the ~ synonym and octave-tracking facility is added. - * Requires tone(), rest(), and endtone(). String play is not interruptible - * except possibly at physical block boundaries. - */ - -typedef int bool; -#define TRUE 1 -#define FALSE 0 - -#define toupper(c) ((c) - ' ' * (((c) >= 'a') && ((c) <= 'z'))) -#define isdigit(c) (((c) >= '0') && ((c) <= '9')) -#define dtoi(c) ((c) - '0') - -static int octave; /* currently selected octave */ -static int whole; /* whole-note time at current tempo, in ticks */ -static int value; /* whole divisor for note time, quarter note = 1 */ -static int fill; /* controls spacing of notes */ -static bool octtrack; /* octave-tracking on? */ -static bool octprefix; /* override current octave-tracking state? */ - -/* - * Magic number avoidance... - */ -#define SECS_PER_MIN 60 /* seconds per minute */ -#define WHOLE_NOTE 4 /* quarter notes per whole note */ -#define MIN_VALUE 64 /* the most we can divide a note by */ -#define DFLT_VALUE 4 /* default value (quarter-note) */ -#define FILLTIME 8 /* for articulation, break note in parts */ -#define STACCATO 6 /* 6/8 = 3/4 of note is filled */ -#define NORMAL 7 /* 7/8ths of note interval is filled */ -#define LEGATO 8 /* all of note interval is filled */ -#define DFLT_OCTAVE 4 /* default octave */ -#define MIN_TEMPO 32 /* minimum tempo */ -#define DFLT_TEMPO 120 /* default tempo */ -#define MAX_TEMPO 255 /* max tempo */ -#define NUM_MULT 3 /* numerator of dot multiplier */ -#define DENOM_MULT 2 /* denominator of dot multiplier */ - -/* letter to half-tone: A B C D E F G */ -static int notetab[8] = {9, 11, 0, 2, 4, 5, 7}; - -/* - * This is the American Standard A440 Equal-Tempered scale with frequencies - * rounded to nearest integer. Thank Goddess for the good ol' CRC Handbook... - * our octave 0 is standard octave 2. - */ -#define OCTAVE_NOTES 12 /* semitones per octave */ -static int pitchtab[] = -{ -/* C C# D D# E F F# G G# A A# B*/ -/* 0 */ 65, 69, 73, 78, 82, 87, 93, 98, 103, 110, 117, 123, -/* 1 */ 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247, -/* 2 */ 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, -/* 3 */ 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, -/* 4 */ 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1975, -/* 5 */ 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951, -/* 6 */ 4186, 4435, 4698, 4978, 5274, 5588, 5920, 6272, 6644, 7040, 7459, 7902, -}; - -static void playinit() -{ - octave = DFLT_OCTAVE; - whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO; - fill = NORMAL; - value = DFLT_VALUE; - octtrack = FALSE; - octprefix = TRUE; /* act as though there was an initial O(n) */ -} - -static void playtone(pitch, value, sustain) -/* play tone of proper duration for current rhythm signature */ -int pitch, value, sustain; -{ - register int sound, silence, snum = 1, sdenom = 1; - - /* this weirdness avoids floating-point arithmetic */ - for (; sustain; sustain--) - { - snum *= NUM_MULT; - sdenom *= DENOM_MULT; - } - - if (pitch == -1) - rest(whole * snum / (value * sdenom)); - else - { - sound = (whole * snum) / (value * sdenom) - - (whole * (FILLTIME - fill)) / (value * FILLTIME); - silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom); - -#ifdef DEBUG - printf("playtone: pitch %d for %d ticks, rest for %d ticks\n", - pitch, sound, silence); -#endif /* DEBUG */ - - tone(pitchtab[pitch], sound); - if (fill != LEGATO) - rest(silence); - } -} - -static int abs(n) -int n; -{ - if (n < 0) - return(-n); - else - return(n); -} - -static void playstring(cp, slen) -/* interpret and play an item from a notation string */ -char *cp; -size_t slen; -{ - int pitch, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE; - -#define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \ - {v = v * 10 + (*++cp - '0'); slen--;} - for (; slen--; cp++) - { - int sustain, timeval, tempo; - register char c = toupper(*cp); - -#ifdef DEBUG - printf("playstring: %c (%x)\n", c, c); -#endif /* DEBUG */ - - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': - - /* compute pitch */ - pitch = notetab[c - 'A'] + octave * OCTAVE_NOTES; - - /* this may be followed by an accidental sign */ - if (cp[1] == '#' || cp[1] == '+') - { - ++pitch; - ++cp; - slen--; - } - else if (cp[1] == '-') - { - --pitch; - ++cp; - slen--; - } - - /* - * If octave-tracking mode is on, and there has been no octave- - * setting prefix, find the version of the current letter note - * closest to the last regardless of octave. - */ - if (octtrack && !octprefix) - { - if (abs(pitch-lastpitch) > abs(pitch+OCTAVE_NOTES-lastpitch)) - { - ++octave; - pitch += OCTAVE_NOTES; - } - - if (abs(pitch-lastpitch) > abs((pitch-OCTAVE_NOTES)-lastpitch)) - { - --octave; - pitch -= OCTAVE_NOTES; - } - } - octprefix = FALSE; - lastpitch = pitch; - - /* ...which may in turn be followed by an override time value */ - GETNUM(cp, timeval); - if (timeval <= 0 || timeval > MIN_VALUE) - timeval = value; - - /* ...and/or sustain dots */ - for (sustain = 0; cp[1] == '.'; cp++) - { - slen--; - sustain++; - } - - /* time to emit the actual tone */ - playtone(pitch, timeval, sustain); - break; - - case 'O': - if (cp[1] == 'N' || cp[1] == 'n') - { - octprefix = octtrack = FALSE; - ++cp; - slen--; - } - else if (cp[1] == 'L' || cp[1] == 'l') - { - octtrack = TRUE; - ++cp; - slen--; - } - else - { - GETNUM(cp, octave); - if (octave >= sizeof(pitchtab) / OCTAVE_NOTES) - octave = DFLT_OCTAVE; - octprefix = TRUE; - } - break; - - case '>': - if (octave < sizeof(pitchtab) / OCTAVE_NOTES - 1) - octave++; - octprefix = TRUE; - break; - - case '<': - if (octave > 0) - octave--; - octprefix = TRUE; - break; - - case 'N': - GETNUM(cp, pitch); - for (sustain = 0; cp[1] == '.'; cp++) - { - slen--; - sustain++; - } - playtone(pitch - 1, value, sustain); - break; - - case 'L': - GETNUM(cp, value); - if (value <= 0 || value > MIN_VALUE) - value = DFLT_VALUE; - break; - - case 'P': - case '~': - /* this may be followed by an override time value */ - GETNUM(cp, timeval); - if (timeval <= 0 || timeval > MIN_VALUE) - timeval = value; - for (sustain = 0; cp[1] == '.'; cp++) - { - slen--; - sustain++; - } - playtone(-1, timeval, sustain); - break; - - case 'T': - GETNUM(cp, tempo); - if (tempo < MIN_TEMPO || tempo > MAX_TEMPO) - tempo = DFLT_TEMPO; - whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / tempo; - break; - - case 'M': - if (cp[1] == 'N' || cp[1] == 'n') - { - fill = NORMAL; - ++cp; - slen--; - } - else if (cp[1] == 'L' || cp[1] == 'l') - { - fill = LEGATO; - ++cp; - slen--; - } - else if (cp[1] == 'S' || cp[1] == 's') - { - fill = STACCATO; - ++cp; - slen--; - } - break; - } - } -} - -/******************* UNIX DRIVER HOOKS BEGIN HERE ************************** - * - * This section implements driver hooks to run playstring() and the tone(), - * endtone(), and rest() functions defined above. - */ - -static int spkr_active; /* exclusion flag */ -static struct buf *spkr_inbuf; /* incoming buf */ - -int spkropen(dev) -dev_t dev; -{ -#ifdef DEBUG - printf("spkropen: entering with dev = %x\n", dev); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else if (spkr_active) - return(EBUSY); - else - { - playinit(); - spkr_inbuf = geteblk(DEV_BSIZE); - spkr_active = 1; - } - return(0); -} - -int spkrwrite(dev, uio) -dev_t dev; -struct uio *uio; -{ - register unsigned n; - char *cp; - int error; -#ifdef DEBUG - printf("spkrwrite: entering with dev = %x, count = %d\n", - dev, uio->uio_resid); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else - { - n = MIN(DEV_BSIZE, uio->uio_resid); - cp = spkr_inbuf->b_un.b_addr; - error = uiomove(cp, n, uio); - if (!error) - playstring(cp, n); - return(error); - } -} - -int spkrclose(dev) -dev_t dev; -{ -#ifdef DEBUG - printf("spkrclose: entering with dev = %x\n", dev); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else - { - endtone(); - brelse(spkr_inbuf); - spkr_active = 0; - } - return(0); -} - -int spkrioctl(dev, cmd, cmdarg) -dev_t dev; -int cmd; -caddr_t cmdarg; -{ -#ifdef DEBUG - printf("spkrioctl: entering with dev = %x, cmd = %x\n", dev, cmd); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else if (cmd == SPKRTONE) - { - tone_t *tp = (tone_t *)cmdarg; - - if (tp->frequency == 0) - rest(tp->duration); - else - tone(tp->frequency, tp->duration); - } - else if (cmd == SPKRTUNE) - { - tone_t *tp = (tone_t *)(*(caddr_t *)cmdarg); - tone_t ttp; - int error; - - for (; ; tp++) { - error = copyin(tp, &ttp, sizeof(tone_t)); - if (error) - return(error); - if (ttp.duration == 0) - break; - if (ttp.frequency == 0) - rest(ttp.duration); - else - tone(ttp.frequency, ttp.duration); - } - } - else - return(EINVAL); - return(0); -} - -#endif /* NSPEAKER > 0 */ -/* spkr.c ends here */ diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c deleted file mode 100644 index 6828aca..0000000 --- a/sys/dev/syscons/syscons.c +++ /dev/null @@ -1,2385 +0,0 @@ -#define STAR_SAVER -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz and Don Ahn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/* - * Heavily modified by Søren Schmidt (sos@kmd-ac.dk) to provide: - * - * virtual consoles, SYSV ioctl's, ANSI emulation - * - * @(#)syscons.c 0.2b 930531 - * - * Further changes 29 July 93 by Jordan Hubbard - provide full pccons and - * FreeBSD compatability. - */ - -#include "param.h" -#include "conf.h" -#include "ioctl.h" -#include "proc.h" -#include "user.h" -#include "tty.h" -#include "uio.h" -#include "callout.h" -#include "systm.h" -#include "kernel.h" -#include "syslog.h" -#include "errno.h" -#include "console.h" -#include "malloc.h" -#include "i386/isa/icu.h" -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "machine/pc/display.h" -#include "i386/i386/cons.h" -#include "machine/psl.h" -#include "machine/frame.h" -#include "sc.h" -#include "ddb.h" -#include "iso8859.font" -#include "kbdtables.h" - -#if NSC > 0 -#ifndef NCONS -#define NCONS 12 -#endif - -/* status flags */ -#define LOCK_KEY_MASK 0x0000F -#define LED_MASK 0x00007 -#define UNKNOWN_MODE 0x00010 -#define KBD_RAW_MODE 0x00020 -#define SWITCH_WAIT_REL 0x00040 -#define SWITCH_WAIT_ACQ 0x00080 - -/* virtual video memory addresses */ -#define MONO_BUF 0xFE0B0000 -#define CGA_BUF 0xFE0B8000 -#define VGA_BUF 0xFE0A0000 -#define VIDEOMEM 0x000A0000 -#define MEMSIZE 0x00020000 - -/* misc defines */ -#define MAX_ESC_PAR 3 -#define TEXT80x25 1 -#define TEXT80x50 2 -#define COL 80 -#define ROW 25 -#ifndef XTALSPEED -#define XTALSPEED 1193182 /* should be in isa.h */ -#endif - -/* defines related to hardware addresses */ -#define MONO_BASE 0x3B4 /* crt controller base mono */ -#define COLOR_BASE 0x3D4 /* crt controller base color */ -#define ATC 0x3C0 /* attribute controller */ -#define TSIDX 0x3C4 /* timing sequencer idx */ -#define TSREG 0x3C5 /* timing sequencer data */ -#define PIXMASK 0x3C6 /* pixel write mask */ -#define PALRADR 0x3C7 /* palette read address */ -#define PALWADR 0x3C8 /* palette write address */ -#define PALDATA 0x3C9 /* palette data register */ -#define GDCIDX 0x3CE /* graph data controller idx */ -#define GDCREG 0x3CF /* graph data controller data */ - -typedef struct term_stat { - int esc; /* processing escape sequence */ - int n_par; /* # of parameters to ESC */ - int last_par; /* last parameter # */ - int par[MAX_ESC_PAR]; /* contains ESC parameters */ - int attr; /* current attributes */ - int std_attr; /* normal attributes */ - int rev_attr; /* reverse attributes */ -} term_stat; - -typedef struct scr_stat { - u_short *crt_base; /* address of screen memory */ - u_short *scr; /* buffer when off screen */ - u_short *crtat; /* cursor address */ - int posx; /* current X position */ - int posy; /* current Y position */ - int max_posx; /* X size */ - int max_posy; /* X size */ - term_stat term; /* terminal emulation stuff */ - char cursor_start; /* cursor start line # */ - char cursor_end; /* cursor start end # */ - u_char border; /* border color */ - u_short bell_duration; - u_short bell_pitch; - u_short status; /* status (bitfield) */ - u_short mode; /* mode */ - pid_t pid; /* pid of controlling proc */ - struct proc *proc; /* proc* of controlling proc */ - struct vt_mode smode; /* switch mode */ -} scr_stat; - -typedef struct default_attr { - int std_attr; /* normal attributes */ - int rev_attr; /* reverse attributes */ -} default_attr; - -static default_attr user_default = { - (FG_LIGHTGREY | BG_BLACK) << 8, - (FG_BLACK | BG_LIGHTGREY) << 8 -}; - -static default_attr kernel_default = { - (FG_WHITE | BG_BLACK) << 8, - (FG_BLACK | BG_LIGHTGREY) << 8 -}; - -static default_attr *current_default; - -static scr_stat cons_scr_stat[NCONS]; -static scr_stat *cur_scr_stat = &cons_scr_stat[0]; -static scr_stat *new_scp, *old_scp; -static term_stat kernel_console; -static int switch_in_progress = 0; - -u_short *Crtat = (u_short *)MONO_BUF; -static u_short *crtat = 0; -static u_int crtc_addr = MONO_BASE; -static char crtc_vga = 0; -static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0; -static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0; -static char palette[3*256]; -static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab); -static int cur_cursor_pos = -1; -static char in_putc, nx_scr; -static char saved_console = -1; /* saved console number */ -static long scrn_blank_time = 0; /* screen saver timout value */ -static int scrn_blanked = 0; /* screen saver active flag */ -static long scrn_time_stamp; -static u_char scr_map[256]; - -struct tty pccons[NCONS]; -struct tty *cur_pccons = &pccons[0]; -struct tty *new_pccons; - -extern int hz; -extern struct timeval time; - -#define CSF_ACTIVE 0x1 /* timeout active */ -#define CSF_POLLING 0x2 /* polling for input */ - -struct pcconsoftc { - char cs_flags; - char cs_lastc; /* last char sent */ - int cs_timo; /* timeouts since interrupt */ - u_long cs_wedgecnt; /* times restarted */ -} pcconsoftc = {0, 0, 0, 0}; - - -/* special characters */ -#define bs 8 -#define lf 10 -#define cr 13 -#define cntlc 3 -#define del 0177 -#define cntld 4 - -/* function prototypes */ -int pcprobe(struct isa_device *dev); -int pcattach(struct isa_device *dev); -int pcopen(dev_t dev, int flag, int mode, struct proc *p); -int pcclose(dev_t dev, int flag, int mode, struct proc *p); -int pcread(dev_t dev, struct uio *uio, int flag); -int pcwrite(dev_t dev, struct uio *uio, int flag); -int pcparam(struct tty *tp, struct termios *t); -int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p); -int pcxint(dev_t dev); -int pcstart(struct tty *tp); -int pccnprobe(struct consdev *cp); -int pccninit(struct consdev *cp); -int pccnputc(dev_t dev, char c); -int pccngetc(dev_t dev); -int scintr(dev_t dev, int irq, int cpl); -void scrn_saver(int test); -static struct tty *get_pccons(dev_t dev); -static scr_stat *get_scr_stat(dev_t dev); -static int get_scr_num(scr_stat *scp); -static void cursor_shape(int start, int end); -static void get_cursor_shape(int *start, int *end); -static void cursor_pos(void); -static void clear_screen(scr_stat *scp); -static switch_scr(u_int next_scr); -static void exchange_scr(void); -static void move_crsr(scr_stat *scp, int x, int y); -static void move_up(u_short *s, u_short *d, u_int len); -static void move_down(u_short *s, u_short *d, u_int len); -static void scan_esc(scr_stat *scp, u_char c); -static void ansi_put(scr_stat *scp, u_char c); -void consinit(void); -static void sput(u_char c); -static u_char *get_fstr(u_int c, u_int *len); -static update_leds(int which); -void reset_cpu(void); -u_int sgetc(int noblock); -int pcmmap(dev_t dev, int offset, int nprot); -int getchar(void); -static void kbd_wait(void); -static void kbd_cmd(u_char command); -static void set_mode(scr_stat *scp); -static void set_border(int color); -static load_font(int segment, int size, char* font); -static void save_palette(void); -static void load_palette(void); -static change_winsize(struct tty *tp, int x, int y); - -struct isa_driver scdriver = { - pcprobe, pcattach, "sc", -}; - - -int pcprobe(struct isa_device *dev) -{ - u_char c; - int again = 0; - - /* Enable interrupts and keyboard controller */ - kbd_wait(); - outb(KB_STAT, KB_WRITE); - kbd_cmd(0x4D); - - /* Start keyboard stuff RESET */ - kbd_cmd(KB_RESET); - while ((c=inb(KB_DATA)) != KB_ACK) { - if ((c == 0xFE) || (c == 0xFF)) { - if (!again) - printf("KEYBOARD disconnected: RECONNECT \n"); - kbd_cmd(KB_RESET); - again = 1; - } - } - kbd_wait(); - return 1; -} - - -int pcattach(struct isa_device *dev) -{ - scr_stat *scp; - int start = -1, end = -1, i; - - if (crtc_vga) - if (crtc_addr == MONO_BASE) - printf(" VGA mono"); - else - printf(" VGA color"); - else - if (crtc_addr == MONO_BASE) - printf(" MDA/hercules"); - else - printf(" CGA/EGA"); - - if (NCONS > 1) - printf(" <%d virtual consoles>\n", NCONS); - else - printf("\n"); - if (crtc_vga) { - get_cursor_shape(&start, &end); - save_palette(); - load_font(0, 16, font_8x16); - load_font(1, 8, font_8x8); - load_font(2, 14, font_8x14); - } - current_default = &user_default; - for (i = 0; i < NCONS; i++) { - scp = &cons_scr_stat[i]; - scp->scr = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT); - scp->mode = TEXT80x25; - scp->term.esc = 0; - scp->term.std_attr = current_default->std_attr; - scp->term.rev_attr = current_default->rev_attr; - scp->term.attr = scp->term.std_attr; - scp->border = BG_BLACK; - scp->cursor_start = start; - scp->cursor_end = end; - scp->max_posx = COL; - scp->max_posy = ROW; - scp->bell_pitch = 800; - scp->bell_duration = 10; - scp->status = 0; - scp->pid = 0; - scp->proc = NULL; - scp->smode.mode = VT_AUTO; - if (i > 0) { - scp->crt_base = scp->crtat = scp->scr; - fillw(scp->term.attr|scr_map[0x20], scp->scr, COL*ROW); - } - } - /* get cursor going */ - cursor_pos(); -} - - -static struct tty *get_pccons(dev_t dev) -{ - int i = minor(dev); - - if (i >= NCONS) - return(NULL); - return(&pccons[i]); -} - - -static scr_stat *get_scr_stat(dev_t dev) -{ - int i = minor(dev); - - if (i >= NCONS) - return(NULL); - return(&cons_scr_stat[i]); -} - - -static int get_scr_num(scr_stat *scp) /* allways call with legal scp !! */ -{ - int i = 0; - - while ((i < NCONS) && (cur_scr_stat != &cons_scr_stat[i])) i++; - return i; -} - -pcopen(dev_t dev, int flag, int mode, struct proc *p) -{ - struct tty *tp = get_pccons(dev); - - if (!tp) - return(ENXIO); - tp->t_oproc = pcstart; - tp->t_param = pcparam; - tp->t_dev = dev; - if ((tp->t_state & TS_ISOPEN) == 0) { - tp->t_state |= TS_WOPEN; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; - pcparam(tp, &tp->t_termios); - ttsetwater(tp); - } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) - return(EBUSY); - tp->t_state |= TS_CARR_ON; - return((*linesw[tp->t_line].l_open)(dev, tp)); -} - - -pcclose(dev_t dev, int flag, int mode, struct proc *p) -{ - struct tty *tp = get_pccons(dev); - struct scr_stat *scp; - - if (!tp) - return(ENXIO); - scp = get_scr_stat(tp->t_dev); - scp->pid = 0; - scp->proc = NULL; - scp->smode.mode = VT_AUTO; - (*linesw[tp->t_line].l_close)(tp, flag); - ttyclose(tp); - return(0); -} - - -pcread(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = get_pccons(dev); - - if (!tp) - return(ENXIO); - return((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - - -pcwrite(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = get_pccons(dev); - - if (!tp) - return(ENXIO); - return((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - - -/* - * Got a console interrupt, keyboard action ! - * Catch the character, and see who it goes to. - */ -scintr(dev_t dev, int irq, int cpl) -{ - int c, len; - u_char *cp; - - /* make screensaver happy */ - scrn_time_stamp = time.tv_sec; - if (scrn_blanked) - scrn_saver(0); - c = sgetc(1); - if (c & 0x100) - return; - if (pcconsoftc.cs_flags & CSF_POLLING) - return; - if (c < 0x100) - (*linesw[cur_pccons->t_line].l_rint)(c & 0xFF, cur_pccons); - else if (cp = get_fstr((u_int)c, (u_int *)&len)) { - while (len-- > 0) - (*linesw[cur_pccons->t_line].l_rint) - (*cp++ & 0xFF, cur_pccons); - } -} - - -/* - * Set line parameters - */ -pcparam(struct tty *tp, struct termios *t) -{ - int cflag = t->c_cflag; - - /* and copy to tty */ - tp->t_ispeed = t->c_ispeed; - tp->t_ospeed = t->c_ospeed; - tp->t_cflag = cflag; - return(0); -} - - -pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) -{ - int error; - struct tty *tp; - struct syscframe *fp; - scr_stat *scp; - - tp = get_pccons(dev); - if (!tp) - return ENXIO; - scp = get_scr_stat(tp->t_dev); - - switch (cmd) { /* process console hardware related ioctl's */ - - case CONS_BLANKTIME: /* set screen saver timeout (0 = no saver) */ - scrn_blank_time = *(int*)data; - return 0; - - case CONS_80x25TEXT: /* set 80x25 text mode */ - if (!crtc_vga) - return ENXIO; - scp->mode = TEXT80x25; - scp->max_posy = 25; - free(scp->scr, M_DEVBUF); - scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2, - M_DEVBUF, M_NOWAIT); - if (scp != cur_scr_stat) - scp->crt_base = scp->scr; - set_mode(scp); - clear_screen(scp); - change_winsize(tp, scp->max_posx, scp->max_posy); - return 0; - - case CONS_80x50TEXT: /* set 80x50 text mode */ - if (!crtc_vga) - return ENXIO; - scp->mode = TEXT80x50; - scp->max_posy = 50; - free(scp->scr, M_DEVBUF); - scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2, - M_DEVBUF, M_NOWAIT); - if (scp != cur_scr_stat) - scp->crt_base = scp->scr; - set_mode(scp); - clear_screen(scp); - change_winsize(tp, scp->max_posx, scp->max_posy); - return 0; - - case CONS_GETINFO: /* get current (virtual) console info */ - if (*data == sizeof(struct vid_info)) { - vid_info_t *ptr = (vid_info_t*)data; - ptr->m_num = get_scr_num(scp); - ptr->mv_col = scp->posx; - ptr->mv_row = scp->posy; - ptr->mv_csz = scp->max_posx; - ptr->mv_rsz = scp->max_posy; - ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8; - ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12; - ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8; - ptr->mv_rev.back = (scp->term.rev_attr & 0xf000)>>12; - ptr->mv_grfc.fore = 0; /* not supported */ - ptr->mv_grfc.back = 0; /* not supported */ - ptr->mv_ovscan = scp->border; - ptr->mk_keylock = scp->status & LOCK_KEY_MASK; - return 0; - } - return EINVAL; - - case VT_SETMODE: /* set screen switcher mode */ - bcopy(data, &scp->smode, sizeof(struct vt_mode)); - if (scp->smode.mode == VT_PROCESS) { - scp->proc = p; - scp->pid = scp->proc->p_pid; - } - return 0; - - case VT_GETMODE: /* get screen switcher mode */ - bcopy(&scp->smode, data, sizeof(struct vt_mode)); - return 0; - - case VT_RELDISP: /* screen switcher ioctl */ - switch(*data) { - case VT_FALSE: /* user refuses to release screen, abort */ - if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { - old_scp->status &= ~SWITCH_WAIT_REL; - switch_in_progress = 0; - return 0; - } - return EINVAL; - - case VT_TRUE: /* user has released screen, go on */ - if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { - scp->status &= ~SWITCH_WAIT_REL; - exchange_scr(); - if (new_scp->smode.mode == VT_PROCESS) { - new_scp->status |= SWITCH_WAIT_ACQ; - psignal(new_scp->proc, - new_scp->smode.acqsig); - } - else - switch_in_progress = 0; - return 0; - } - return EINVAL; - - case VT_ACKACQ: /* acquire acknowledged, switch completed */ - if (scp == new_scp && (scp->status & SWITCH_WAIT_ACQ)) { - scp->status &= ~SWITCH_WAIT_ACQ; - switch_in_progress = 0; - return 0; - } - return EINVAL; - - default: - return EINVAL; - } - /* NOT REACHED */ - - case VT_OPENQRY: /* return free virtual cons, allways current */ - *data = get_scr_num(scp); - return 0; - - case VT_ACTIVATE: /* switch to screen *data */ - return switch_scr((*data) - 1); - - case VT_WAITACTIVE: /* wait for switch to occur */ - if (*data > NCONS) - return EINVAL; - if (minor(dev) == (*data) - 1) - return 0; - if (*data == 0) { - if (scp == cur_scr_stat) - return 0; - while ((error=tsleep(&scp->smode, - PZERO|PCATCH, "waitvt", 0)) - == ERESTART) ; - } - else - while ((error=tsleep(&cons_scr_stat[*data].smode, - PZERO|PCATCH, "waitvt", 0)) - == ERESTART) ; - return error; - - case KDENABIO: /* allow io operations */ - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags |= PSL_IOPL; - return 0; - - case KDDISABIO: /* disallow io operations (default) */ - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags &= ~PSL_IOPL; - return 0; - - case KDSETMODE: /* set current mode of this (virtual) console */ - switch (*data) { - case KD_TEXT: /* switch to TEXT (known) mode */ - /* restore fonts & palette ! */ - if (crtc_vga) { - load_font(0, 16, font_8x16); - load_font(1, 8, font_8x8); - load_font(2, 14, font_8x14); - load_palette(); - } - /* FALL THROUGH */ - - case KD_TEXT1: /* switch to TEXT (known) mode */ - /* no restore fonts & palette */ - scp->status &= ~UNKNOWN_MODE; - set_mode(scp); - clear_screen(scp); - return 0; - - case KD_GRAPHICS:/* switch to GRAPHICS (unknown) mode */ - scp->status |= UNKNOWN_MODE; - return 0; - default: - return EINVAL; - } - /* NOT REACHED */ - - case KDGETMODE: /* get current mode of this (virtual) console */ - *data = (scp->status & UNKNOWN_MODE) ? KD_GRAPHICS : KD_TEXT; - return 0; - - case KDSBORDER: /* set border color of this (virtual) console */ - if (!crtc_vga) - return ENXIO; - scp->border = *data; - if (scp == cur_scr_stat) - set_border(scp->border); - return 0; - - case KDSKBSTATE: /* set keyboard state (locks) */ - if (*data >= 0 && *data <= LOCK_KEY_MASK) { - scp->status &= ~LOCK_KEY_MASK; - scp->status |= *data; - if (scp == cur_scr_stat) - update_leds(scp->status & LED_MASK); - return 0; - } - return EINVAL; - - case KDGKBSTATE: /* get keyboard state (locks) */ - *data = scp->status & LOCK_KEY_MASK; - return 0; - - case KDSETRAD: /* set keyboard repeat & delay rates */ - if (*(u_char*)data < 0x80) { - kbd_cmd(KB_SETRAD); - kbd_cmd(*data & 0x7f); - return 0; - } - return EINVAL; - - case KDSKBMODE: /* set keyboard mode */ - switch (*data) { - case K_RAW: /* switch to RAW scancode mode */ - scp->status |= KBD_RAW_MODE; - return 0; - - case K_XLATE: /* switch to XLT ascii mode */ - scp->status &= ~KBD_RAW_MODE; - return 0; - default: - return EINVAL; - } - /* NOT REACHED */ - - case KDGKBMODE: /* get keyboard mode */ - *data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE; - return 0; - - case KDMKTONE: /* sound the bell */ - if (scp == cur_scr_stat) - sysbeep(scp->bell_pitch, scp->bell_duration); - return 0; - - case KIOCSOUND: /* make tone (*data) hz */ - if (scp == cur_scr_stat) { - if (*(int*)data) { - int pitch = XTALSPEED/(*(int*)data); - /* enable counter 2 */ - outb(0x61, inb(0x61) | 3); - /* set command for counter 2, 2 byte write */ - outb(0x43, 0xb6); - /* set pitch */ - outb(0x42, pitch); - outb(0x42, (pitch>>8)); - } - else { - /* disable counter 2 */ - outb(0x61, inb(0x61) & 0xFC); - } - } - return 0; - - case KDGKBTYPE: /* get keyboard type */ - *data = 0; /* type not known (yet) */ - return 0; - - case KDSETLED: /* set keyboard LED status */ - if (*data >= 0 && *data <= LED_MASK) { - scp->status &= ~LED_MASK; - scp->status |= *data; - if (scp == cur_scr_stat) - update_leds(scp->status & LED_MASK); - return 0; - } - return EINVAL; - - case KDGETLED: /* get keyboard LED status */ - *data = scp->status & LED_MASK; - return 0; - - case GETFKEY: /* get functionkey string */ - if (*(u_short*)data < n_fkey_tab) { - fkeyarg_t *ptr = (fkeyarg_t*)data; - bcopy(&fkey_tab[ptr->keynum].str, - ptr->keydef, - fkey_tab[ptr->keynum].len); - ptr->flen = fkey_tab[ptr->keynum].len; - return 0; - } - else - return EINVAL; - - case SETFKEY: /* set functionkey string */ - if (*(u_short*)data < n_fkey_tab) { - fkeyarg_t *ptr = (fkeyarg_t*)data; - bcopy(ptr->keydef, - &fkey_tab[ptr->keynum].str, - min(ptr->flen, MAXFK)); - fkey_tab[ptr->keynum].len = min(ptr->flen, MAXFK); - return 0; - } - else - return EINVAL; - - case GIO_SCRNMAP: /* get output translation table */ - bcopy(&scr_map, data, sizeof(scr_map)); - return 0; - - case PIO_SCRNMAP: /* set output translation table */ - bcopy(data, &scr_map, sizeof(scr_map)); - return 0; - - case GIO_KEYMAP: /* get keyboard translation table */ - bcopy(&key_map, data, sizeof(key_map)); - return 0; - - case PIO_KEYMAP: /* set keyboard translation table */ - bcopy(data, &key_map, sizeof(key_map)); - return 0; - - case PIO_FONT8x8: /* set 8x8 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(data, &font_8x8, sizeof(font_8x8)); - load_font(1, 8, font_8x8); - return 0; - - case GIO_FONT8x8: /* get 8x8 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(&font_8x8, data, sizeof(font_8x8)); - return 0; - - case PIO_FONT8x14: /* set 8x14 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(data, &font_8x14, sizeof(font_8x14)); - load_font(2, 14, font_8x14); - return 0; - - case GIO_FONT8x14: /* get 8x14 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(&font_8x14, data, sizeof(font_8x14)); - return 0; - - case PIO_FONT8x16: /* set 8x16 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(data, &font_8x16, sizeof(font_8x16)); - load_font(0, 16, font_8x16); - return 0; - - case GIO_FONT8x16: /* get 8x16 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(&font_8x16, data, sizeof(font_8x16)); - return 0; - - case CONSOLE_X_MODE_ON: /* just to be compatible */ - if (saved_console < 0) { - saved_console = get_scr_num(cur_scr_stat); - switch_scr(minor(dev)); - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags |= PSL_IOPL; - scp->status |= UNKNOWN_MODE; - scp->status |= KBD_RAW_MODE; - return 0; - } - return EAGAIN; - - case CONSOLE_X_MODE_OFF:/* just to be compatible */ - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags &= ~PSL_IOPL; - if (crtc_vga) { - load_font(0, 16, font_8x16); - load_font(1, 8, font_8x8); - load_font(2, 14, font_8x14); - load_palette(); - } - scp->status &= ~UNKNOWN_MODE; - set_mode(scp); - clear_screen(scp); - scp->status &= ~KBD_RAW_MODE; - switch_scr(saved_console); - saved_console = -1; - return 0; - - case CONSOLE_X_BELL: - /* - * if set, data is a pointer to a length 2 array of - * integers. data[0] is the pitch in Hz and data[1] - * is the duration in msec. - */ - if (data) - sysbeep(1187500/ ((int*)data)[0], - ((int*)data)[1] * hz/ 3000); - else - sysbeep(0x31b, hz/4); - return 0; - - default: - break; - } - - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag); - if (error >= 0) - return(error); - error = ttioctl(tp, cmd, data, flag); - if (error >= 0) - return(error); - return(ENOTTY); -} - - -pcxint(dev_t dev) -{ - pccons[minor(dev)].t_state &= ~TS_BUSY; - pcconsoftc.cs_timo = 0; - if (pccons[minor(dev)].t_line) - (*linesw[pccons[minor(dev)].t_line].l_start) - (&pccons[minor(dev)]); - else - pcstart(&pccons[minor(dev)]); -} - - -pcstart(struct tty *tp) -{ - int c, s; - scr_stat *scp = get_scr_stat(tp->t_dev); - - s = spltty(); - if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))) - for (;;) { - if (RB_LEN(&tp->t_out) <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_out); - } - if (tp->t_wsel) { - selwakeup(tp->t_wsel, - tp->t_state & TS_WCOLL); - tp->t_wsel = 0; - tp->t_state &= ~TS_WCOLL; - } - } - if (RB_LEN(&tp->t_out) == 0) - break; - if (scp->status & SLKED) - break; - c = getc(&tp->t_out); - tp->t_state |= TS_BUSY; - splx(s); - ansi_put(scp, c); - s = spltty(); - tp->t_state &= ~TS_BUSY; - } - splx(s); -} - - -pccnprobe(struct consdev *cp) -{ - int maj; - - /* locate the major number */ - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == pcopen) - break; - - /* initialize required fields */ - cp->cn_dev = makedev(maj, 0); - cp->cn_tp = &pccons[0]; - cp->cn_pri = CN_INTERNAL; -} - - -pccninit(struct consdev *cp) -{ -} - - -pccnputc(dev_t dev, char c) -{ - int pos; - - if (cur_scr_stat->status & UNKNOWN_MODE) - return; - if (c == '\n') - sput('\r'); - sput(c); - pos = cur_scr_stat->crtat - cur_scr_stat->crt_base; - if (pos != cur_cursor_pos) { - cur_cursor_pos = pos; - outb(crtc_addr,14); - outb(crtc_addr+1,pos >> 8); - outb(crtc_addr,15); - outb(crtc_addr+1,pos&0xff); - } -} - - -pccngetc(dev_t dev) -{ - int c, s; - - s = spltty(); /* block scintr while we poll */ - c = sgetc(0); - splx(s); - if (c == '\r') c = '\n'; - return(c); -} - -#if !defined(STAR_SAVER) && !defined(SNAKE_SAVER) - -void scrn_saver(int test) -{ - u_char val; - - if (test) { - scrn_blanked = 1; - outb(TSIDX, 0x01); val = inb(TSREG); - outb(TSIDX, 0x01); outb(TSREG, val | 0x20); - } - else { - scrn_blanked = 0; - outb(TSIDX, 0x01); val = inb(TSREG); - outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); - } -} -#endif -#if defined(STAR_SAVER) || defined(SNAKE_SAVER) - -static u_long rand_next = 1; - -static rand() -{ - return ((rand_next = rand_next * 1103515245 + 12345) & 0x7FFFFFFF); -} -#endif -#ifdef STAR_SAVER -/* - * Alternate saver that got its inspiration from a well known utility - * package for an unfamous OS. - */ - -#define NUM_STARS 50 - -void scrn_saver(int test) -{ - scr_stat *scp = cur_scr_stat; - int cell, i; - char pattern[] = {"...........++++*** "}; - char colors[] = {FG_DARKGREY, FG_LIGHTGREY, - FG_WHITE, FG_LIGHTCYAN}; - static u_short stars[NUM_STARS][2]; - - if (test) { - if (!scrn_blanked) { - bcopy(Crtat, scp->scr, - scp->max_posx * scp->max_posy * 2); - fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], Crtat, - scp->max_posx * scp->max_posy); - set_border(0); - i = scp->max_posy * scp->max_posx + 5; - outb(crtc_addr, 14); - outb(crtc_addr+1, i >> 8); - outb(crtc_addr, 15); - outb(crtc_addr+1, i & 0xff); - scrn_blanked = 1; - for(i=0; i<NUM_STARS; i++) { - stars[i][0] = - rand() % (scp->max_posx*scp->max_posy); - stars[i][1] = 0; - } - } - cell = rand() % NUM_STARS; - *((u_short*)(Crtat + stars[cell][0])) = - scr_map[pattern[stars[cell][1]]] | - colors[rand()%sizeof(colors)] << 8; - if ((stars[cell][1]+=(rand()%4)) >= sizeof(pattern)-1) { - stars[cell][0] = rand() % (scp->max_posx*scp->max_posy); - stars[cell][1] = 0; - } - } - else { - if (scrn_blanked) { - bcopy(scp->scr, Crtat, scp->max_posx*scp->max_posy*2); - cur_cursor_pos = -1; - set_border(scp->border); - scrn_blanked = 0; - } - } -} -#endif -#ifdef SNAKE_SAVER -/* - * alternative screen saver for cards that do not like blanking - */ - -void scrn_saver(int test) -{ - const char saves[] = {"386BSD"}; - static u_char *savs[sizeof(saves)-1]; - static int dirx, diry; - int f; - scr_stat *scp = cur_scr_stat; - - if (test) { - if (!scrn_blanked) { - bcopy(Crtat, scp->scr, - scp->max_posx * scp->max_posy * 2); - fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], Crtat, - scp->max_posx * scp->max_posy); - set_border(0); - dirx = (scp->posx ? 1 : -1); - diry = (scp->posy ? - scp->max_posx : -scp->max_posx); - for (f=0; f< sizeof(saves)-1; f++) - savs[f] = (u_char *)Crtat + 2 * - (scp->posx+scp->posy*scp->max_posx); - *(savs[0]) = scr_map[*saves]; - f = scp->max_posy * scp->max_posx + 5; - outb(crtc_addr, 14); - outb(crtc_addr+1, f >> 8); - outb(crtc_addr, 15); - outb(crtc_addr+1, f & 0xff); - scrn_blanked = 1; - } - if (scrn_blanked++ < 4) - return; - scrn_blanked = 1; - *(savs[sizeof(saves)-2]) = scr_map[0x20]; - for (f=sizeof(saves)-2; f > 0; f--) - savs[f] = savs[f-1]; - f = (savs[0] - (u_char *)Crtat) / 2; - if ((f % scp->max_posx) == 0 || - (f % scp->max_posx) == scp->max_posx - 1 || - (rand() % 50) == 0) - dirx = -dirx; - if ((f / scp->max_posx) == 0 || - (f / scp->max_posx) == scp->max_posy - 1 || - (rand() % 20) == 0) - diry = -diry; - savs[0] += 2*dirx + 2*diry; - for (f=sizeof(saves)-2; f>=0; f--) - *(savs[f]) = scr_map[saves[f]]; - } - else { - if (scrn_blanked) { - bcopy(scp->scr, Crtat, - scp->max_posx * scp->max_posy * 2); - cur_cursor_pos = -1; - set_border(scp->border); - scrn_blanked = 0; - } - } -} -#endif - -static void cursor_shape(int start, int end) -{ - outb(crtc_addr, 10); - outb(crtc_addr+1, start & 0xFF); - outb(crtc_addr, 11); - outb(crtc_addr+1, end & 0xFF); -} - - -static void get_cursor_shape(int *start, int *end) -{ - outb(crtc_addr, 10); - *start = inb(crtc_addr+1) & 0x1F; - outb(crtc_addr, 11); - *end = inb(crtc_addr+1) & 0x1F; -} - - -static void cursor_pos(void) -{ - int pos; - - if (cur_scr_stat->status & UNKNOWN_MODE) - return; - if (scrn_blank_time && (time.tv_sec > scrn_time_stamp+scrn_blank_time)) - scrn_saver(1); - pos = cur_scr_stat->crtat - cur_scr_stat->crt_base; - if (!scrn_blanked && pos != cur_cursor_pos) { - cur_cursor_pos = pos; - outb(crtc_addr, 14); - outb(crtc_addr+1, pos>>8); - outb(crtc_addr, 15); - outb(crtc_addr+1, pos&0xff); - } - timeout(cursor_pos, 0, hz/20); -} - - -static void clear_screen(scr_stat *scp) -{ - move_crsr(scp, 0, 0); - fillw(scp->term.attr | scr_map[0x20], scp->crt_base, - scp->max_posx * scp->max_posy); -} - - -static switch_scr(u_int next_scr) -{ - if (in_putc) { /* don't switch if in putc */ - nx_scr = next_scr+1; - return 0; - } - if (switch_in_progress && - (cur_scr_stat->proc != pfind(cur_scr_stat->pid))) - switch_in_progress = 0; - if (next_scr >= NCONS || switch_in_progress) { - sysbeep(800, hz/4); - return -1; - } - switch_in_progress = 1; - old_scp = cur_scr_stat; - new_scp = &cons_scr_stat[next_scr]; - wakeup(&new_scp->smode); - if (new_scp == old_scp) { - switch_in_progress = 0; - return 0; - } - new_pccons = &pccons[next_scr]; - - /* has controlling process died? */ - if (old_scp->proc && (old_scp->proc != pfind(old_scp->pid))) - old_scp->smode.mode = VT_AUTO; - if (new_scp->proc && (new_scp->proc != pfind(new_scp->pid))) - new_scp->smode.mode = VT_AUTO; - - /* check the modes and switch approbiatly */ - if (old_scp->smode.mode == VT_PROCESS) { - old_scp->status |= SWITCH_WAIT_REL; - psignal(old_scp->proc, old_scp->smode.relsig); - } - else { - exchange_scr(); - if (new_scp->smode.mode == VT_PROCESS) { - new_scp->status |= SWITCH_WAIT_ACQ; - psignal(new_scp->proc, new_scp->smode.acqsig); - } - else - switch_in_progress = 0; - } - return 0; -} - - -static void exchange_scr(void) -{ - bcopy(Crtat, old_scp->scr, old_scp->max_posx * old_scp->max_posy * 2); - old_scp->crt_base = old_scp->scr; - move_crsr(old_scp, old_scp->posx, old_scp->posy); - cur_scr_stat = new_scp; - cur_pccons = new_pccons; - if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE) - shfts = ctls = alts = 0; - update_leds(new_scp->status & LED_MASK); - set_mode(new_scp); - new_scp->crt_base = Crtat; - move_crsr(new_scp, new_scp->posx, new_scp->posy); - bcopy(new_scp->scr, Crtat, new_scp->max_posx * new_scp->max_posy * 2); - nx_scr = 0; -} - - -static void move_crsr(scr_stat *scp, int x, int y) -{ - if (x < 0 || y < 0 || x >= scp->max_posx || y >= scp->max_posy) - return; - scp->posx = x; - scp->posy = y; - scp->crtat = scp->crt_base + scp->posy * scp->max_posx + scp->posx; -} - - -static void move_up(u_short *s, u_short *d, u_int len) -{ - s += len; - d += len; - while (len-- > 0) - *--d = *--s; -} - - -static void move_down(u_short *s, u_short *d, u_int len) -{ - while (len-- > 0) - *d++ = *s++; -} - - -static void scan_esc(scr_stat *scp, u_char c) -{ - static u_char ansi_col[16] = - {0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15}; - int i, n; - u_short *src, *dst, count; - - if (scp->term.esc == 1) { - switch (c) { - - case '[': /* Start ESC [ sequence */ - scp->term.esc = 2; - scp->term.last_par = -1; - for (i = scp->term.n_par; i < MAX_ESC_PAR; i++) - scp->term.par[i] = 1; - scp->term.n_par = 0; - return; - - case 'M': /* Move cursor up 1 line, scroll if at top */ - if (scp->posy > 0) - move_crsr(scp, scp->posx, scp->posy - 1); - else { - move_up(scp->crt_base, - scp->crt_base + scp->max_posx, - (scp->max_posy - 1) * scp->max_posx); - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base, scp->max_posx); - } - break; -#if notyet - case 'Q': - scp->term.esc = 4; - break; -#endif - case 'c': /* Clear screen & home */ - clear_screen(scp); - break; - } - } - else if (scp->term.esc == 2) { - if (c >= '0' && c <= '9') { - if (scp->term.n_par < MAX_ESC_PAR) { - if (scp->term.last_par != scp->term.n_par) { - scp->term.last_par = scp->term.n_par; - scp->term.par[scp->term.n_par] = 0; - } - else - scp->term.par[scp->term.n_par] *= 10; - scp->term.par[scp->term.n_par] += c - '0'; - return; - } - } - scp->term.n_par = scp->term.last_par + 1; - switch (c) { - - case ';': - if (scp->term.n_par < MAX_ESC_PAR) - return; - break; - - case '=': - scp->term.esc = 3; - scp->term.last_par = -1; - for (i = scp->term.n_par; i < MAX_ESC_PAR; i++) - scp->term.par[i] = 1; - scp->term.n_par = 0; - return; - - case 'A': /* up n rows */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, scp->posy - n); - break; - - case 'B': /* down n rows */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, scp->posy + n); - break; - - case 'C': /* right n columns */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx + n, scp->posy); - break; - - case 'D': /* left n columns */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx - n, scp->posy); - break; - - case 'E': /* cursor to start of line n lines down */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, 0, scp->posy + n); - break; - - case 'F': /* cursor to start of line n lines up */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, 0, scp->posy - n); - break; - - case 'f': /* System V consoles .. */ - case 'H': /* Cursor move */ - if (scp->term.n_par == 0) - move_crsr(scp, 0, 0); - else if (scp->term.n_par == 2) - move_crsr(scp, scp->term.par[1] - 1, - scp->term.par[0] - 1); - break; - - case 'J': /* Clear all or part of display */ - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* clear form cursor to end of display */ - fillw(scp->term.attr | scr_map[0x20], - scp->crtat, scp->crt_base + - scp->max_posx * scp->max_posy - - scp->crtat); - break; - case 1: /* clear from beginning of display to cursor */ - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base, - scp->crtat - scp->crt_base); - break; - case 2: /* clear entire display */ - clear_screen(scp); - break; - } - break; - - case 'K': /* Clear all or part of line */ - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* clear form cursor to end of line */ - fillw(scp->term.attr | scr_map[0x20], - scp->crtat, scp->max_posx - scp->posx); - break; - case 1: /* clear from beginning of line to cursor */ - fillw(scp->term.attr|scr_map[0x20], - scp->crtat - (scp->max_posx - scp->posx), - (scp->max_posx - scp->posx) + 1); - break; - case 2: /* clear entire line */ - fillw(scp->term.attr|scr_map[0x20], - scp->crtat - (scp->max_posx - scp->posx), - scp->max_posx); - break; - } - break; - - case 'L': /* Insert n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posy - scp->posy) - n = scp->max_posy - scp->posy; - src = scp->crt_base + scp->posy * scp->max_posx; - dst = src + n * scp->max_posx; - count = scp->max_posy - (scp->posy + n); - move_up(src, dst, count * scp->max_posx); - fillw(scp->term.attr | scr_map[0x20], src, - n * scp->max_posx); - break; - - case 'M': /* Delete n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posy - scp->posy) - n = scp->max_posy - scp->posy; - dst = scp->crt_base + scp->posy * scp->max_posx; - src = dst + n * scp->max_posx; - count = scp->max_posy - (scp->posy + n); - move_down(src, dst, count * scp->max_posx); - src = dst + count * scp->max_posx; - fillw(scp->term.attr | scr_map[0x20], src, - n * scp->max_posx); - break; - - case 'P': /* Delete n chars */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posx - scp->posx) - n = scp->max_posx - scp->posx; - dst = scp->crtat; - src = dst + n; - count = scp->max_posx - (scp->posx + n); - move_down(src, dst, count); - src = dst + count; - fillw(scp->term.attr | scr_map[0x20], src, n); - break; - - case '@': /* Insert n chars */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posx - scp->posx) - n = scp->max_posx - scp->posx; - src = scp->crtat; - dst = src + n; - count = scp->max_posx - (scp->posx + n); - move_up(src, dst, count); - fillw(scp->term.attr | scr_map[0x20], src, n); - break; - - case 'S': /* scroll up n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - bcopy(scp->crt_base + (scp->max_posx * n), - scp->crt_base, - scp->max_posx * (scp->max_posy - n) * - sizeof(u_short)); - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base + scp->max_posx * - (scp->max_posy - 1), - scp->max_posx); - break; - - case 'T': /* scroll down n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - bcopy(scp->crt_base, - scp->crt_base + (scp->max_posx * n), - scp->max_posx * (scp->max_posy - n) * - sizeof(u_short)); - fillw(scp->term.attr | scr_map[0x20], scp->crt_base, - scp->max_posx); - break; - - case 'X': /* delete n characters in line */ - n = scp->term.par[0]; if (n < 1) n = 1; - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base + scp->posx + - ((scp->max_posx*scp->posy) * sizeof(u_short)), n); - break; - - case 'Z': /* move n tabs backwards */ - n = scp->term.par[0]; if (n < 1) n = 1; - if ((i = scp->posx & 0xf8) == scp->posx) - i -= 8*n; - else - i -= 8*(n-1); - if (i < 0) - i = 0; - move_crsr(scp, i, scp->posy); - break; - - case '`': /* move cursor to column n */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, n, scp->posy); - break; - - case 'a': /* move cursor n columns to the right */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx + n, scp->posy); - break; - - case 'd': /* move cursor to row n */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, n); - break; - - case 'e': /* move cursor n rows down */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, scp->posy + n); - break; - - case 'm': /* change attribute */ - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* back to normal */ - scp->term.attr = scp->term.std_attr; - break; - case 1: /* highlight (bold) */ - scp->term.attr &= 0xFF00; - scp->term.attr |= 0x0800; - break; - case 4: /* highlight (underline) */ - scp->term.attr &= 0x0F00; - scp->term.attr |= 0x0800; - break; - case 5: /* blink */ - scp->term.attr &= 0xFF00; - scp->term.attr |= 0x8000; - break; - case 7: /* reverse video */ - scp->term.attr = scp->term.rev_attr; - break; - case 30: case 31: case 32: case 33: /* set fg color */ - case 34: case 35: case 36: case 37: - scp->term.attr = (scp->term.attr & 0xF0FF) - | (ansi_col[(n - 30) & 7] << 8); - break; - case 40: case 41: case 42: case 43: /* set bg color */ - case 44: case 45: case 46: case 47: - scp->term.attr = (scp->term.attr & 0x0FFF) - | (ansi_col[(n - 40) & 7] << 12); - break; - } - break; - - case 'x': - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* reset attributes */ - scp->term.attr = scp->term.std_attr = - current_default->std_attr; - scp->term.rev_attr = current_default->rev_attr; - break; - case 1: /* set ansi background */ - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0x0F00) | - (ansi_col[(scp->term.par[1])&0x0F]<<12); - break; - case 2: /* set ansi foreground */ - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0xF000) | - (ansi_col[(scp->term.par[1])&0x0F]<<8); - break; - case 3: /* set ansi attribute directly */ - scp->term.attr = scp->term.std_attr = - (scp->term.par[1]&0xFF)<<8; - break; - case 5: /* set ansi reverse video background */ - scp->term.rev_attr = - (scp->term.rev_attr & 0x0F00) | - (ansi_col[(scp->term.par[1])&0x0F]<<12); - break; - case 6: /* set ansi reverse video foreground */ - scp->term.rev_attr = - (scp->term.rev_attr & 0xF000) | - (ansi_col[(scp->term.par[1])&0x0F]<<8); - break; - case 7: /* set ansi reverse video directly */ - scp->term.rev_attr = (scp->term.par[1]&0xFF)<<8; - break; - } - break; - - case 'z': /* switch to (virtual) console n */ - if (scp->term.n_par == 1) - switch_scr(scp->term.par[0]); - break; - } - } - else if (scp->term.esc == 3) { - if (c >= '0' && c <= '9') { - if (scp->term.n_par < MAX_ESC_PAR) { - if (scp->term.last_par != scp->term.n_par) { - scp->term.last_par = scp->term.n_par; - scp->term.par[scp->term.n_par] = 0; - } - else - scp->term.par[scp->term.n_par] *= 10; - scp->term.par[scp->term.n_par] += c - '0'; - return; - } - } - scp->term.n_par = scp->term.last_par + 1; - switch (c) { - - case ';': - if (scp->term.n_par < MAX_ESC_PAR) - return; - break; - - case 'A': /* set display border color */ - if (scp->term.n_par == 1) - scp->border=scp->term.par[0] & 0xff; - if (scp == cur_scr_stat) - set_border(scp->border); - break; - - case 'B': /* set bell pitch and duration */ - if (scp->term.n_par == 2) { - scp->bell_pitch = scp->term.par[0]; - scp->bell_duration = scp->term.par[1]*10; - } - break; - - case 'C': /* set cursor shape (start & end line) */ - if (scp->term.n_par == 2) { - scp->cursor_start = scp->term.par[0] & 0x1F; - scp->cursor_end = scp->term.par[1] & 0x1F; - if (scp == cur_scr_stat) - cursor_shape(scp->cursor_start, - scp->cursor_end); - } - break; - - case 'F': /* set ansi foreground */ - if (scp->term.n_par == 1) - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0xF000) - | ((scp->term.par[0] & 0x0F) << 8); - break; - - case 'G': /* set ansi background */ - if (scp->term.n_par == 1) - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0x0F00) - | ((scp->term.par[0] & 0x0F) << 12); - break; - - case 'H': /* set ansi reverse video foreground */ - if (scp->term.n_par == 1) - scp->term.rev_attr = - (scp->term.rev_attr & 0xF000) - | ((scp->term.par[0] & 0x0F) << 8); - break; - - case 'I': /* set ansi reverse video background */ - if (scp->term.n_par == 1) - scp->term.rev_attr = - (scp->term.rev_attr & 0x0F00) - | ((scp->term.par[0] & 0x0F) << 12); - break; - } - } - scp->term.esc = 0; -} - - -static void ansi_put(scr_stat *scp, u_char c) -{ - if (scp->status & UNKNOWN_MODE) - return; - - /* make screensaver happy */ - if (scp == cur_scr_stat) { - scrn_time_stamp = time.tv_sec; - if (scrn_blanked) - scrn_saver(0); - } - in_putc++; - if (scp->term.esc) - scan_esc(scp, c); - else switch(c) { - case 0x1B: /* start escape sequence */ - scp->term.esc = 1; - scp->term.n_par = 0; - break; - case 0x07: - if (scp == cur_scr_stat) - sysbeep(scp->bell_pitch, scp->bell_duration); - break; - case '\t': /* non-destructive tab */ - scp->crtat += (8 - scp->posx % 8); - scp->posx += (8 - scp->posx % 8); - break; - case '\b': /* non-destructive backspace */ - if (scp->crtat > scp->crt_base) { - scp->crtat--; - if (scp->posx > 0) - scp->posx--; - else { - scp->posx += scp->max_posx - 1; - scp->posy--; - } - } - break; - case '\r': /* return to pos 0 */ - move_crsr(scp, 0, scp->posy); - break; - case '\n': /* newline, same pos */ - scp->crtat += scp->max_posx; - scp->posy++; - break; - case '\f': /* form feed, clears screen */ - clear_screen(scp); - break; - default: - /* Print only printables */ - *scp->crtat = (scp->term.attr | scr_map[c]); - scp->crtat++; - if (++scp->posx >= scp->max_posx) { - scp->posx = 0; - scp->posy++; - } - break; - } - if (scp->crtat >= scp->crt_base + scp->max_posy * scp->max_posx) { - bcopy(scp->crt_base + scp->max_posx, scp->crt_base, - scp->max_posx * (scp->max_posy - 1) * sizeof(u_short)); - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base + scp->max_posx * (scp->max_posy - 1), - scp->max_posx); - scp->crtat -= scp->max_posx; - scp->posy--; - } - in_putc--; - if (nx_scr) - switch_scr(nx_scr - 1); -} - - -void consinit(void) -{ - u_short *cp = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short), was; - unsigned cursorat; - int i; - - /* - * catch that once in a blue moon occurence when consinit is called - * TWICE, adding the CGA_BUF offset again -> poooff - */ - if (crtat != 0) - return; - /* - * Crtat initialized to point to MONO buffer, if not present change - * to CGA_BUF offset. ONLY ADD the difference since locore.s adds - * in the remapped offset at the right time - */ - was = *cp; - *cp = (u_short) 0xA55A; - if (*cp != 0xA55A) { - crtc_addr = MONO_BASE; - } else { - *cp = was; - crtc_addr = COLOR_BASE; - Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short); - } - - /* Extract cursor location */ - outb(crtc_addr,14); - cursorat = inb(crtc_addr+1)<<8 ; - outb(crtc_addr,15); - cursorat |= inb(crtc_addr+1); - crtat = Crtat + cursorat; - - /* is this a VGA or higher ? */ - outb(crtc_addr, 7); - if (inb(crtc_addr) == 7) - crtc_vga = 1; - - current_default = &user_default; - cons_scr_stat[0].crtat = crtat; - cons_scr_stat[0].crt_base = Crtat; - cons_scr_stat[0].term.esc = 0; - cons_scr_stat[0].term.std_attr = current_default->std_attr; - cons_scr_stat[0].term.rev_attr = current_default->rev_attr; - cons_scr_stat[0].term.attr = current_default->std_attr; - cons_scr_stat[0].posx = cursorat % COL; - cons_scr_stat[0].posy = cursorat / COL; - cons_scr_stat[0].border = BG_BLACK;; - cons_scr_stat[0].max_posx = COL; - cons_scr_stat[0].max_posy = ROW; - cons_scr_stat[0].status = 0; - cons_scr_stat[0].pid = 0; - cons_scr_stat[0].proc = NULL; - cons_scr_stat[0].smode.mode = VT_AUTO; - cons_scr_stat[0].bell_pitch = 800; - cons_scr_stat[0].bell_duration = 10; - kernel_console.esc = 0; - kernel_console.std_attr = kernel_default.std_attr; - kernel_console.rev_attr = kernel_default.rev_attr; - kernel_console.attr = kernel_default.std_attr; - /* initialize mapscrn array to */ - for (i=0; i<sizeof(scr_map); i++) - scr_map[i] = i; - clear_screen(&cons_scr_stat[0]); -} - - -static void sput(u_char c) -{ - scr_stat *scp = &cons_scr_stat[0]; - term_stat save; - - if (crtat == 0) - consinit(); - save = scp->term; - scp->term = kernel_console; - current_default = &kernel_default; - ansi_put(scp, c); - kernel_console = scp->term; - current_default = &user_default; - scp->term = save; -} - - -static u_char *get_fstr(u_int c, u_int *len) -{ - u_int i; - - if (!(c & FKEY)) - return(NULL); - i = (c & 0xFF) - F_FN; - if (i > n_fkey_tab) - return(NULL); - *len = fkey_tab[i].len; - return(fkey_tab[i].str); -} - - -static update_leds(int which) -{ - u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 }; - - kbd_cmd(KB_SETLEDS); /* LED Command */ - kbd_cmd(xlate_leds[which & LED_MASK]); - kbd_wait(); -} - - -volatile void reset_cpu(void) -{ - while (1) { - kbd_cmd(KB_RESET_CPU); /* Reset Command */ - DELAY(4000000); - kbd_cmd(KB_RESET); /* Keyboard Reset Command */ - } -} - - -/* - * sgetc(noblock) : get a character from the keyboard. - * If noblock = 0 wait until a key is gotten. Otherwise return a 0x100. - */ -u_int sgetc(int noblock) -{ - u_char val, code, release; - u_int state, action; - struct key_t *key; - static u_char esc_flag = 0, compose = 0; - static u_int chr = 0; - -next_code: - kbd_wait(); - /* First see if there is something in the keyboard port */ - if (inb(KB_STAT) & KB_BUF_FULL) - val = inb(KB_DATA); - else if (noblock) - return(0x100); - else - goto next_code; - - if (cur_scr_stat->status & KBD_RAW_MODE) - return val; - - code = val & 0x7F; - release = val & 0x80; - - /* Check for cntl-alt-del */ - if ((code == 83) && ctls && alts) - cpu_reset(); -#if NDDB > 0 - /* Check for cntl-alt-esc */ - if ((val == 1) && ctls && alts) { - /* if debugger called, try to switch to console 0 */ - if (cur_scr_stat->smode.mode == VT_AUTO && - cons_scr_stat[0].smode.mode == VT_AUTO) - switch_scr(0); - Debugger(); - return(0x100); - } -#endif - switch (esc_flag) { - case 0x00: /* normal scancode */ - switch(code) { - case 0x38: /* left alt (compose key) */ - if (release && compose) { - compose = 0; - if (chr > 255) { - sysbeep(500, hz/4); - chr = 0; - } - } - else { - if (!compose) { - compose = 1; - chr = 0; - } - } - break; - case 0x60: - case 0x61: - esc_flag = code; - goto next_code; - } - break; - case 0x60: /* 0xE0 prefix */ - esc_flag = 0; - switch (code) { - case 0x1d: /* right ctrl key */ - break; - case 0x35: /* keypad divide key */ - code = 0x5b; - break; - case 0x37: /* print scrn key */ - code = 0x5c; - break; - case 0x38: /* right alt key (alt gr) */ - code = 0x5d; - break; - case 0x47: /* grey home key */ - code = 0x5e; - break; - case 0x48: /* grey up arrow key */ - code = 0x5f; - break; - case 0x49: /* grey page up key */ - code = 0x60; - break; - case 0x4b: /* grey left arrow key */ - code = 0x61; - break; - case 0x4d: /* grey right arrow key */ - code = 0x62; - break; - case 0x4f: /* grey end key */ - code = 0x63; - break; - case 0x50: /* grey down arrow key */ - code = 0x64; - break; - case 0x51: /* grey page down key */ - code = 0x65; - break; - case 0x52: /* grey insert key */ - code = 0x66; - break; - case 0x53: /* grey delete key */ - code = 0x67; - break; - default: /* ignore everything else */ - goto next_code; - } - break; - case 0x61: /* 0xE1 prefix */ - esc_flag = 0; - if (code == 0x1D) - esc_flag = 0x1D; - goto next_code; - /* NOT REACHED */ - case 0x1D: /* pause / break */ - esc_flag = 0; - if (code != 0x45) - goto next_code; - code = 0x68; - break; - } - - if (compose) { - switch (code) { - case 0x47: - case 0x48: /* keypad 7,8,9 */ - case 0x49: - if (!release) - chr = (code - 0x40) + chr*10; - goto next_code; - case 0x4b: - case 0x4c: /* keypad 4,5,6 */ - case 0x4d: - if (!release) - chr = (code - 0x47) + chr*10; - goto next_code; - case 0x4f: - case 0x50: /* keypad 1,2,3 */ - case 0x51: - if (!release) - chr = (code - 0x4e) + chr*10; - goto next_code; - case 0x52: /* keypad 0 */ - if (!release) - chr *= 10; - goto next_code; - case 0x38: /* left alt key */ - break; - default: - if (chr) { - compose = chr = 0; - sysbeep(500, hz/4); - goto next_code; - } - break; - } - } - - state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0)); - if ((!agrs && (cur_scr_stat->status & ALKED)) - || (agrs && !(cur_scr_stat->status & ALKED))) - code += ALTGR_OFFSET; - key = &key_map.key[code]; - if ( ((key->flgs & FLAG_LOCK_C) && (cur_scr_stat->status & CLKED)) - || ((key->flgs & FLAG_LOCK_N) && (cur_scr_stat->status & NLKED)) ) - state ^= 1; - - /* Check for make/break */ - action = key->map[state]; - if (release) { /* key released */ - if (key->spcl & 0x80) { - switch (action) { - case LSH: - shfts &= ~1; - break; - case RSH: - shfts &= ~2; - break; - case LCTR: - ctls &= ~1; - break; - case RCTR: - ctls &= ~2; - break; - case LALT: - alts &= ~1; - break; - case RALT: - alts &= ~2; - break; - case NLK: - nlkcnt = 0; - break; - case CLK: - clkcnt = 0; - break; - case SLK: - slkcnt = 0; - break; - case ASH: - agrs = 0; - break; - } - } - if (chr && !compose) { - action = chr; - chr = 0; - return (action); - } - } else { - /* key pressed */ - if (key->spcl & (0x80>>state)) { - switch (action) { - /* LOCKING KEYS */ - case NLK: - if (!nlkcnt) { - nlkcnt++; - if (cur_scr_stat->status & NLKED) - cur_scr_stat->status &= ~NLKED; - else - cur_scr_stat->status |= NLKED; - update_leds(cur_scr_stat->status & LED_MASK); - } - break; - case CLK: - if (!clkcnt) { - clkcnt++; - if (cur_scr_stat->status & CLKED) - cur_scr_stat->status &= ~CLKED; - else - cur_scr_stat->status |= CLKED; - update_leds(cur_scr_stat->status & LED_MASK); - } - break; - case SLK: - if (!slkcnt) { - slkcnt++; - if (cur_scr_stat->status & SLKED) { - cur_scr_stat->status &= ~SLKED; - pcstart(&pccons[get_scr_num(cur_scr_stat)]); - } - else - cur_scr_stat->status |= SLKED; - update_leds(cur_scr_stat->status & LED_MASK); - } - break; - case ALK: - if (!alkcnt) { - alkcnt++; - if (cur_scr_stat->status & ALKED) - cur_scr_stat->status &= ~ALKED; - else - cur_scr_stat->status |= ALKED; - } - break; - - /* NON-LOCKING KEYS */ - case LSH: - shfts |= 1; - break; - case RSH: - shfts |= 2; - break; - case LCTR: - ctls |= 1; - break; - case RCTR: - ctls |= 2; - break; - case LALT: - alts |= 1; - break; - case RALT: - alts |= 2; - break; - case ASH: - agrs = 1; - break; - case NOP: - break; - default: - if (action >= F_SCR && action <= L_SCR) { - switch_scr(action - F_SCR); - break; - } - if (action >= F_FN && action <= L_FN) { - return(action | FKEY); - } - return(action); - } - } - else return(action); - } - goto next_code; -} - -/* July '93, jkh. Added in for init_main.c */ -void cons_highlight() -{ - cons_scr_stat[0].term.attr &= 0xFF00; - cons_scr_stat[0].term.attr |= 0x0800; -} - -void cons_normal() -{ - cons_scr_stat[0].term.attr = cons_scr_stat[0].term.std_attr; -} - -int getchar(void) -{ - char thechar; - int s; - - pcconsoftc.cs_flags |= CSF_POLLING; - s = splhigh(); - sput('>'); - thechar = (char) sgetc(0); - pcconsoftc.cs_flags &= ~CSF_POLLING; - splx(s); - switch (thechar) { - default: - if (thechar >= scr_map[0x20]) - sput(thechar); - return(thechar); - case cr: - case lf: - sput(cr); sput(lf); - return(lf); - case bs: - case del: - sput(bs); sput(scr_map[0x20]); sput(bs); - return(thechar); - case cntld: - sput('^'); sput('D'); sput('\r'); sput('\n'); - return(0); - } -} - - -int pcmmap(dev_t dev, int offset, int nprot) -{ - if (offset > 0x20000) - return EINVAL; - return i386_btop((VIDEOMEM + offset)); -} - - -static void kbd_wait(void) -{ - int i; - for (i=0; i<10000; i++) - if ((inb(KB_STAT) & KB_READY) == 0) - break; -} - - -static void kbd_cmd(u_char command) -{ - kbd_wait(); - outb(KB_DATA, command); -} - - -static void set_mode(scr_stat *scp) -{ - u_char byte; - int s; - - if (scp != cur_scr_stat) - return; - - /* (re)activate cursor */ - untimeout(cursor_pos, 0); - cursor_pos(); - - /* change cursor type if set */ - if (scp->cursor_start != -1 && scp->cursor_end != -1) - cursor_shape(scp->cursor_start, scp->cursor_end); - - /* mode change only on VGA's */ - if (!crtc_vga) - return; - - /* setup video hardware for the given mode */ - s = splhigh(); - switch(scp->mode) { - case TEXT80x25: - outb(crtc_addr, 9); byte = inb(crtc_addr+1); - outb(crtc_addr, 9); outb(crtc_addr+1, byte | 0x0F); - outb(TSIDX, 0x03); outb(TSREG, 0x00); /* select font 0 */ - break; - case TEXT80x50: - outb(crtc_addr, 9); byte = inb(crtc_addr+1); - outb(crtc_addr, 9); outb(crtc_addr+1, (byte & 0xF0) | 0x07); - outb(TSIDX, 0x03); outb(TSREG, 0x05); /* select font 1 */ - break; - default: - return; - } - splx(s); - - /* set border color for this (virtual) console */ - set_border(scp->border); - return; -} - - -static void set_border(int color) -{ - inb(crtc_addr+6); /* reset flip-flop */ - outb(ATC, 0x11); outb(ATC, color); - inb(crtc_addr+6); /* reset flip-flop */ - outb(ATC, 0x20); /* enable Palette */ -} - -static load_font(int segment, int size, char* font) -{ - int ch, line, s; - u_char val; - - outb(TSIDX, 0x01); val = inb(TSREG); /* blank screen */ - outb(TSIDX, 0x01); outb(TSREG, val | 0x20); - - /* setup vga for loading fonts (graphics plane mode) */ - s = splhigh(); - inb(crtc_addr+6); /* reset flip/flop */ - outb(ATC, 0x30); outb(ATC, 0x01); - outb(TSIDX, 0x02); outb(TSREG, 0x04); - outb(TSIDX, 0x04); outb(TSREG, 0x06); - outb(GDCIDX, 0x04); outb(GDCREG, 0x02); - outb(GDCIDX, 0x05); outb(GDCREG, 0x00); - outb(GDCIDX, 0x06); outb(GDCREG, 0x05); /* addr = a0000, 64kb */ - splx(s); - for (ch=0; ch < 256; ch++) - for (line=0; line < size; line++) - *((char *)atdevbase+(segment*0x4000)+(ch*32)+line) = - font[(ch*size)+line]; - /* setup vga for text mode again */ - s = splhigh(); - inb(crtc_addr+6); /* reset flip/flop */ - outb(ATC, 0x30); outb(ATC, 0x0C); - outb(TSIDX, 0x02); outb(TSREG, 0x03); - outb(TSIDX, 0x04); outb(TSREG, 0x02); - outb(GDCIDX, 0x04); outb(GDCREG, 0x00); - outb(GDCIDX, 0x05); outb(GDCREG, 0x10); - if (crtc_addr == MONO_BASE) { - outb(GDCIDX, 0x06); outb(GDCREG, 0x0A); /* addr = b0000, 32kb */ - } - else { - outb(GDCIDX, 0x06); outb(GDCREG, 0x0E); /* addr = b8000, 32kb */ - } - splx(s); - outb(TSIDX, 0x01); val = inb(TSREG); /* unblank screen */ - outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); -} - - -static void load_palette(void) -{ - int i; - - outb(PIXMASK, 0xFF); /* no pixelmask */ - outb(PALWADR, 0x00); - for (i=0x00; i<0x300; i++) - outb(PALDATA, palette[i]); - inb(crtc_addr+6); /* reset flip/flop */ - outb(ATC, 0x20); /* enable palette */ -} - -static void save_palette(void) -{ - int i; - - outb(PALRADR, 0x00); - for (i=0x00; i<0x300; i++) - palette[i] = inb(PALDATA); - inb(crtc_addr+6); /* reset flip/flop */ -} - - -static change_winsize(struct tty *tp, int x, int y) -{ - if (tp->t_winsize.ws_col != x || tp->t_winsize.ws_row != y) { - tp->t_winsize.ws_col = x; - tp->t_winsize.ws_row = y; - pgsignal(tp->t_pgrp, SIGWINCH, 1); - } -} - -#endif /* NSC */ |