git: 3da598388943 - main - Remove versatile support
Andrew Turner
andrew at FreeBSD.org
Mon Apr 12 08:41:08 UTC 2021
The branch main has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=3da598388943b428bfd165c4d80d0428a23b61f1
commit 3da598388943b428bfd165c4d80d0428a23b61f1
Author: Andrew Turner <andrew at FreeBSD.org>
AuthorDate: 2021-04-11 13:26:50 +0000
Commit: Andrew Turner <andrew at FreeBSD.org>
CommitDate: 2021-04-12 06:16:31 +0000
Remove versatile support
It was used for testing armv6 under QEMU, however since then we added
support for the QEMU virt platform.
Reviewed by: imp, manu
Differential Revision: https://reviews.freebsd.org/D29707
---
sys/arm/annapurna/alpine/files.alpine | 2 +-
sys/arm/arm/pl190.c | 311 ------------
sys/arm/{versatile => arm}/sp804.c | 0
sys/arm/conf/VERSATILEPB | 75 ---
sys/arm/versatile/files.versatile | 9 -
sys/arm/versatile/pl050.c | 742 ---------------------------
sys/arm/versatile/versatile_clcd.c | 921 ----------------------------------
sys/arm/versatile/versatile_machdep.c | 104 ----
sys/arm/versatile/versatile_pci.c | 548 --------------------
sys/arm/versatile/versatile_scm.c | 144 ------
sys/arm/versatile/versatile_scm.h | 49 --
sys/arm/versatile/versatile_sic.c | 324 ------------
12 files changed, 1 insertion(+), 3228 deletions(-)
diff --git a/sys/arm/annapurna/alpine/files.alpine b/sys/arm/annapurna/alpine/files.alpine
index 6724b45ec505..9b00d1db2d5d 100644
--- a/sys/arm/annapurna/alpine/files.alpine
+++ b/sys/arm/annapurna/alpine/files.alpine
@@ -1,6 +1,6 @@
# $FreeBSD$
-arm/versatile/sp804.c standard
+arm/arm/sp804.c standard
dev/uart/uart_dev_ns8250.c optional uart
arm/annapurna/alpine/alpine_machdep.c standard
diff --git a/sys/arm/arm/pl190.c b/sys/arm/arm/pl190.c
deleted file mode 100644
index a8ca18effb8c..000000000000
--- a/sys/arm/arm/pl190.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2012-2017 Oleksandr Tymoshenko <gonzo at bluezbox.com>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/ktr.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/rman.h>
-#include <machine/bus.h>
-#include <machine/intr.h>
-
-#include <dev/ofw/openfirm.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include "pic_if.h"
-
-#ifdef DEBUG
-#define dprintf(fmt, args...) printf(fmt, ##args)
-#else
-#define dprintf(fmt, args...)
-#endif
-
-#define VICIRQSTATUS 0x000
-#define VICFIQSTATUS 0x004
-#define VICRAWINTR 0x008
-#define VICINTSELECT 0x00C
-#define VICINTENABLE 0x010
-#define VICINTENCLEAR 0x014
-#define VICSOFTINT 0x018
-#define VICSOFTINTCLEAR 0x01C
-#define VICPROTECTION 0x020
-#define VICPERIPHID 0xFE0
-#define VICPRIMECELLID 0xFF0
-
-#define VIC_NIRQS 32
-
-struct pl190_intc_irqsrc {
- struct intr_irqsrc isrc;
- u_int irq;
-};
-
-struct pl190_intc_softc {
- device_t dev;
- struct mtx mtx;
- struct resource * intc_res;
- struct pl190_intc_irqsrc isrcs[VIC_NIRQS];
-};
-
-#define INTC_VIC_READ_4(sc, reg) \
- bus_read_4(sc->intc_res, (reg))
-#define INTC_VIC_WRITE_4(sc, reg, val) \
- bus_write_4(sc->intc_res, (reg), (val))
-
-#define VIC_LOCK(_sc) mtx_lock_spin(&(_sc)->mtx)
-#define VIC_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->mtx)
-
-static inline void
-pl190_intc_irq_dispatch(struct pl190_intc_softc *sc, u_int irq,
- struct trapframe *tf)
-{
- struct pl190_intc_irqsrc *src;
-
- src = &sc->isrcs[irq];
- if (intr_isrc_dispatch(&src->isrc, tf) != 0)
- device_printf(sc->dev, "Stray irq %u detected\n", irq);
-}
-
-static int
-pl190_intc_intr(void *arg)
-{
- struct pl190_intc_softc *sc;
- u_int cpu;
- uint32_t num, pending;
- struct trapframe *tf;
-
- sc = arg;
- cpu = PCPU_GET(cpuid);
- tf = curthread->td_intr_frame;
-
- VIC_LOCK(sc);
- pending = INTC_VIC_READ_4(sc, VICIRQSTATUS);
- VIC_UNLOCK(sc);
- for (num = 0 ; num < VIC_NIRQS; num++) {
- if (pending & (1 << num))
- pl190_intc_irq_dispatch(sc, num, tf);
- }
-
- return (FILTER_HANDLED);
-}
-
-static void
-pl190_intc_disable_intr(device_t dev, struct intr_irqsrc *isrc)
-{
- struct pl190_intc_softc *sc;
- struct pl190_intc_irqsrc *src;
-
- sc = device_get_softc(dev);
- src = (struct pl190_intc_irqsrc *)isrc;
-
- VIC_LOCK(sc);
- INTC_VIC_WRITE_4(sc, VICINTENCLEAR, (1 << src->irq));
- VIC_UNLOCK(sc);
-}
-
-static void
-pl190_intc_enable_intr(device_t dev, struct intr_irqsrc *isrc)
-{
- struct pl190_intc_softc *sc;
- struct pl190_intc_irqsrc *src;
-
- sc = device_get_softc(dev);
- src = (struct pl190_intc_irqsrc *)isrc;
-
- VIC_LOCK(sc);
- INTC_VIC_WRITE_4(sc, VICINTENABLE, (1 << src->irq));
- VIC_UNLOCK(sc);
-}
-
-static int
-pl190_intc_map_intr(device_t dev, struct intr_map_data *data,
- struct intr_irqsrc **isrcp)
-{
- struct intr_map_data_fdt *daf;
- struct pl190_intc_softc *sc;
-
- if (data->type != INTR_MAP_DATA_FDT)
- return (ENOTSUP);
-
- daf = (struct intr_map_data_fdt *)data;
- if (daf->ncells != 1 || daf->cells[0] >= VIC_NIRQS)
- return (EINVAL);
-
- sc = device_get_softc(dev);
- *isrcp = &sc->isrcs[daf->cells[0]].isrc;
- return (0);
-}
-
-static void
-pl190_intc_pre_ithread(device_t dev, struct intr_irqsrc *isrc)
-{
- pl190_intc_disable_intr(dev, isrc);
-}
-
-static void
-pl190_intc_post_ithread(device_t dev, struct intr_irqsrc *isrc)
-{
- struct pl190_intc_irqsrc *src;
-
- src = (struct pl190_intc_irqsrc *)isrc;
- pl190_intc_enable_intr(dev, isrc);
- arm_irq_memory_barrier(src->irq);
-}
-
-static void
-pl190_intc_post_filter(device_t dev, struct intr_irqsrc *isrc)
-{
- struct pl190_intc_irqsrc *src;
-
- src = (struct pl190_intc_irqsrc *)isrc;
- arm_irq_memory_barrier(src->irq);
-}
-
-static int
-pl190_intc_setup_intr(device_t dev, struct intr_irqsrc *isrc,
- struct resource *res, struct intr_map_data *data)
-{
-
- return (0);
-}
-
-static int
-pl190_intc_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "arm,versatile-vic"))
- return (ENXIO);
- device_set_desc(dev, "ARM PL190 VIC");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-pl190_intc_attach(device_t dev)
-{
- struct pl190_intc_softc *sc;
- uint32_t id;
- int i, rid;
- struct pl190_intc_irqsrc *isrcs;
- struct intr_pic *pic;
- int error;
- uint32_t irq;
- const char *name;
- phandle_t xref;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
- mtx_init(&sc->mtx, device_get_nameunit(dev), "pl190",
- MTX_SPIN);
-
- /* Request memory resources */
- rid = 0;
- sc->intc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
- RF_ACTIVE);
- if (sc->intc_res == NULL) {
- device_printf(dev, "Error: could not allocate memory resources\n");
- return (ENXIO);
- }
-
- /*
- * All interrupts should use IRQ line
- */
- INTC_VIC_WRITE_4(sc, VICINTSELECT, 0x00000000);
- /* Disable all interrupts */
- INTC_VIC_WRITE_4(sc, VICINTENCLEAR, 0xffffffff);
-
- id = 0;
- for (i = 3; i >= 0; i--) {
- id = (id << 8) |
- (INTC_VIC_READ_4(sc, VICPERIPHID + i*4) & 0xff);
- }
-
- device_printf(dev, "Peripheral ID: %08x\n", id);
-
- id = 0;
- for (i = 3; i >= 0; i--) {
- id = (id << 8) |
- (INTC_VIC_READ_4(sc, VICPRIMECELLID + i*4) & 0xff);
- }
-
- device_printf(dev, "PrimeCell ID: %08x\n", id);
-
- /* PIC attachment */
- isrcs = sc->isrcs;
- name = device_get_nameunit(sc->dev);
- for (irq = 0; irq < VIC_NIRQS; irq++) {
- isrcs[irq].irq = irq;
- error = intr_isrc_register(&isrcs[irq].isrc, sc->dev,
- 0, "%s,%u", name, irq);
- if (error != 0)
- return (error);
- }
-
- xref = OF_xref_from_node(ofw_bus_get_node(sc->dev));
- pic = intr_pic_register(sc->dev, xref);
- if (pic == NULL)
- return (ENXIO);
-
- return (intr_pic_claim_root(sc->dev, xref, pl190_intc_intr, sc, 0));
-}
-
-static device_method_t pl190_intc_methods[] = {
- DEVMETHOD(device_probe, pl190_intc_probe),
- DEVMETHOD(device_attach, pl190_intc_attach),
-
- DEVMETHOD(pic_disable_intr, pl190_intc_disable_intr),
- DEVMETHOD(pic_enable_intr, pl190_intc_enable_intr),
- DEVMETHOD(pic_map_intr, pl190_intc_map_intr),
- DEVMETHOD(pic_post_filter, pl190_intc_post_filter),
- DEVMETHOD(pic_post_ithread, pl190_intc_post_ithread),
- DEVMETHOD(pic_pre_ithread, pl190_intc_pre_ithread),
- DEVMETHOD(pic_setup_intr, pl190_intc_setup_intr),
-
- DEVMETHOD_END
-};
-
-static driver_t pl190_intc_driver = {
- "intc",
- pl190_intc_methods,
- sizeof(struct pl190_intc_softc),
-};
-
-static devclass_t pl190_intc_devclass;
-
-EARLY_DRIVER_MODULE(intc, simplebus, pl190_intc_driver, pl190_intc_devclass,
- 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/arm/versatile/sp804.c b/sys/arm/arm/sp804.c
similarity index 100%
rename from sys/arm/versatile/sp804.c
rename to sys/arm/arm/sp804.c
diff --git a/sys/arm/conf/VERSATILEPB b/sys/arm/conf/VERSATILEPB
deleted file mode 100644
index 3312f6d4f9e8..000000000000
--- a/sys/arm/conf/VERSATILEPB
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# VERSATILEPB - Configuration for QEMU version of Versatile Platform Board
-#
-# For more information on this file, please read the config(5) manual page,
-# and/or the handbook section on Kernel Configuration Files:
-#
-# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
-#
-# The handbook is also available locally in /usr/share/doc/handbook
-# if you've installed the doc distribution, otherwise always see the
-# FreeBSD World Wide Web server (https://www.FreeBSD.org/) for the
-# latest information.
-#
-# An exhaustive list of options and more detailed explanations of the
-# device lines is also present in the ../../conf/NOTES and NOTES files.
-# If you are in doubt as to the purpose or necessity of a line, check first
-# in NOTES.
-#
-# $FreeBSD$
-
-ident VERSATILEPB
-machine arm armv6
-cpu CPU_ARM1176
-
-include "std.armv6"
-files "../versatile/files.versatile"
-makeoptions MODULES_OVERRIDE=""
-
-options KERNVIRTADDR=0xc0100000
-makeoptions KERNVIRTADDR=0xc0100000
-
-options SCHED_4BSD # 4BSD scheduler
-options LINUX_BOOT_ABI # Process metadata passed from Linux boot loaders
-
-options ROOTDEVNAME=\"ufs:da0s1a\"
-
-device bpf
-device loop
-device mii
-device mii_bitbang
-device smc
-device smcphy
-device ether
-device uart
-device pl011
-device pl190
-
-device pty
-device snp
-
-device pci
-
-# SCSI Controllers
-device sym # NCR/Symbios/LSI Logic 53C8XX/53C1010/53C1510D
-
-# ATA/SCSI peripherals
-device scbus # SCSI bus (required for ATA/SCSI)
-device da # Direct Access (disks)
-device pass # Passthrough device (direct ATA/SCSI access)
-
-# NOTE: serial console is disabled if syscons enabled
-# Comment following lines for headless setup
-device sc
-device kbdmux
-options SC_DFLT_FONT # compile font in
-makeoptions SC_DFLT_FONT=cp437
-
-device md
-
-options PLATFORM
-
-# Flattened Device Tree
-options FDT # Configure using FDT/DTB data
-options FDT_DTB_STATIC
-makeoptions FDT_DTS_FILE=versatile-pb.dts
diff --git a/sys/arm/versatile/files.versatile b/sys/arm/versatile/files.versatile
deleted file mode 100644
index 7e772aba4b0e..000000000000
--- a/sys/arm/versatile/files.versatile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-arm/versatile/pl050.c optional sc
-arm/versatile/sp804.c standard
-arm/versatile/versatile_machdep.c standard
-arm/versatile/versatile_clcd.c optional sc
-arm/versatile/versatile_pci.c optional pci
-arm/versatile/versatile_scm.c standard
-arm/versatile/versatile_sic.c standard
diff --git a/sys/arm/versatile/pl050.c b/sys/arm/versatile/pl050.c
deleted file mode 100644
index cccb4a947c6e..000000000000
--- a/sys/arm/versatile/pl050.c
+++ /dev/null
@@ -1,742 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo at freebsd.org>
- * All rights reserved.
- *
- * Based on dev/usb/input/ukbd.c
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/malloc.h>
-#include <sys/mutex.h>
-#include <sys/rman.h>
-#include <sys/proc.h>
-#include <sys/sched.h>
-#include <sys/kdb.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/intr.h>
-
-#include <dev/ofw/openfirm.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <sys/ioccom.h>
-#include <sys/filio.h>
-#include <sys/kbio.h>
-
-#include <dev/kbd/kbdreg.h>
-
-#include <machine/bus.h>
-
-#include <dev/kbd/kbdtables.h>
-
-#define KMI_LOCK() mtx_lock(&Giant)
-#define KMI_UNLOCK() mtx_unlock(&Giant)
-
-#ifdef INVARIANTS
-/*
- * Assert that the lock is held in all contexts
- * where the code can be executed.
- */
-#define KMI_LOCK_ASSERT() mtx_assert(&Giant, MA_OWNED)
-/*
- * Assert that the lock is held in the contexts
- * where it really has to be so.
- */
-#define KMI_CTX_LOCK_ASSERT() \
- do { \
- if (!kdb_active && !KERNEL_PANICKED()) \
- mtx_assert(&Giant, MA_OWNED); \
- } while (0)
-#else
-#define KMI_LOCK_ASSERT() (void)0
-#define KMI_CTX_LOCK_ASSERT() (void)0
-#endif
-
-#define KMICR 0x00
-#define KMICR_TYPE_NONPS2 (1 << 5)
-#define KMICR_RXINTREN (1 << 4)
-#define KMICR_TXINTREN (1 << 3)
-#define KMICR_EN (1 << 2)
-#define KMICR_FKMID (1 << 1)
-#define KMICR_FKMIC (1 << 0)
-#define KMISTAT 0x04
-#define KMISTAT_TXEMPTY (1 << 6)
-#define KMISTAT_TXBUSY (1 << 5)
-#define KMISTAT_RXFULL (1 << 4)
-#define KMISTAT_RXBUSY (1 << 3)
-#define KMISTAT_RXPARITY (1 << 2)
-#define KMISTAT_KMIC (1 << 1)
-#define KMISTAT_KMID (1 << 0)
-#define KMIDATA 0x08
-#define KMICLKDIV 0x0C
-#define KMIIR 0x10
-#define KMIIR_TXINTR (1 << 1)
-#define KMIIR_RXINTR (1 << 0)
-
-#define KMI_DRIVER_NAME "kmi"
-#define KMI_NFKEY (sizeof(fkey_tab)/sizeof(fkey_tab[0])) /* units */
-
-#define SET_SCANCODE_SET 0xf0
-
-struct kmi_softc {
- device_t sc_dev;
- keyboard_t sc_kbd;
- keymap_t sc_keymap;
- accentmap_t sc_accmap;
- fkeytab_t sc_fkeymap[KMI_NFKEY];
-
- struct resource* sc_mem_res;
- struct resource* sc_irq_res;
- void* sc_intr_hl;
-
- int sc_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */
- int sc_state; /* shift/lock key state */
- int sc_accents; /* accent key index (> 0) */
- uint32_t sc_flags; /* flags */
-#define KMI_FLAG_COMPOSE 0x00000001
-#define KMI_FLAG_POLLING 0x00000002
-
- struct thread *sc_poll_thread;
-};
-
-/* Read/Write macros for Timer used as timecounter */
-#define pl050_kmi_read_4(sc, reg) \
- bus_read_4((sc)->sc_mem_res, (reg))
-
-#define pl050_kmi_write_4(sc, reg, val) \
- bus_write_4((sc)->sc_mem_res, (reg), (val))
-
-/* prototypes */
-static void kmi_set_leds(struct kmi_softc *, uint8_t);
-static int kmi_set_typematic(keyboard_t *, int);
-static uint32_t kmi_read_char(keyboard_t *, int);
-static void kmi_clear_state(keyboard_t *);
-static int kmi_ioctl(keyboard_t *, u_long, caddr_t);
-static int kmi_enable(keyboard_t *);
-static int kmi_disable(keyboard_t *);
-
-static int kmi_attached = 0;
-
-/* early keyboard probe, not supported */
-static int
-kmi_configure(int flags)
-{
- return (0);
-}
-
-/* detect a keyboard, not used */
-static int
-kmi_probe(int unit, void *arg, int flags)
-{
- return (ENXIO);
-}
-
-/* reset and initialize the device, not used */
-static int
-kmi_init(int unit, keyboard_t **kbdp, void *arg, int flags)
-{
- return (ENXIO);
-}
-
-/* test the interface to the device, not used */
-static int
-kmi_test_if(keyboard_t *kbd)
-{
- return (0);
-}
-
-/* finish using this keyboard, not used */
-static int
-kmi_term(keyboard_t *kbd)
-{
- return (ENXIO);
-}
-
-/* keyboard interrupt routine, not used */
-static int
-kmi_intr(keyboard_t *kbd, void *arg)
-{
-
- return (0);
-}
-
-/* lock the access to the keyboard, not used */
-static int
-kmi_lock(keyboard_t *kbd, int lock)
-{
- return (1);
-}
-
-/*
- * Enable the access to the device; until this function is called,
- * the client cannot read from the keyboard.
- */
-static int
-kmi_enable(keyboard_t *kbd)
-{
-
- KMI_LOCK();
- KBD_ACTIVATE(kbd);
- KMI_UNLOCK();
-
- return (0);
-}
-
-/* disallow the access to the device */
-static int
-kmi_disable(keyboard_t *kbd)
-{
-
- KMI_LOCK();
- KBD_DEACTIVATE(kbd);
- KMI_UNLOCK();
-
- return (0);
-}
-
-/* check if data is waiting */
-static int
-kmi_check(keyboard_t *kbd)
-{
- struct kmi_softc *sc = kbd->kb_data;
- uint32_t reg;
-
- KMI_CTX_LOCK_ASSERT();
-
- if (!KBD_IS_ACTIVE(kbd))
- return (0);
-
- reg = pl050_kmi_read_4(sc, KMIIR);
- return (reg & KMIIR_RXINTR);
-}
-
-/* check if char is waiting */
-static int
-kmi_check_char_locked(keyboard_t *kbd)
-{
- KMI_CTX_LOCK_ASSERT();
-
- if (!KBD_IS_ACTIVE(kbd))
- return (0);
-
- return (kmi_check(kbd));
-}
-
-static int
-kmi_check_char(keyboard_t *kbd)
-{
- int result;
-
- KMI_LOCK();
- result = kmi_check_char_locked(kbd);
- KMI_UNLOCK();
-
- return (result);
-}
-
-/* read one byte from the keyboard if it's allowed */
-/* Currently unused. */
-static int
-kmi_read(keyboard_t *kbd, int wait)
-{
- KMI_CTX_LOCK_ASSERT();
-
- if (!KBD_IS_ACTIVE(kbd))
- return (-1);
-
- ++(kbd->kb_count);
- printf("Implement ME: %s\n", __func__);
- return (0);
-}
-
-/* read char from the keyboard */
-static uint32_t
-kmi_read_char_locked(keyboard_t *kbd, int wait)
-{
- struct kmi_softc *sc = kbd->kb_data;
- uint32_t reg, data;
-
- KMI_CTX_LOCK_ASSERT();
-
- if (!KBD_IS_ACTIVE(kbd))
- return (NOKEY);
-
- reg = pl050_kmi_read_4(sc, KMIIR);
- if (reg & KMIIR_RXINTR) {
- data = pl050_kmi_read_4(sc, KMIDATA);
- return (data);
- }
-
- ++kbd->kb_count;
- return (NOKEY);
-}
-
-/* Currently wait is always false. */
-static uint32_t
-kmi_read_char(keyboard_t *kbd, int wait)
-{
- uint32_t keycode;
-
- KMI_LOCK();
- keycode = kmi_read_char_locked(kbd, wait);
- KMI_UNLOCK();
-
- return (keycode);
-}
-
-/* some useful control functions */
-static int
-kmi_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
-{
- struct kmi_softc *sc = kbd->kb_data;
- int i;
-#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
- defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
- int ival;
-
-#endif
-
- KMI_LOCK_ASSERT();
-
- switch (cmd) {
- case KDGKBMODE: /* get keyboard mode */
- *(int *)arg = sc->sc_mode;
- break;
-#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
- defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
- case _IO('K', 7):
- ival = IOCPARM_IVAL(arg);
- arg = (caddr_t)&ival;
- /* FALLTHROUGH */
-#endif
- case KDSKBMODE: /* set keyboard mode */
- switch (*(int *)arg) {
- case K_XLATE:
- if (sc->sc_mode != K_XLATE) {
- /* make lock key state and LED state match */
- sc->sc_state &= ~LOCK_MASK;
- sc->sc_state |= KBD_LED_VAL(kbd);
- }
- /* FALLTHROUGH */
- case K_RAW:
- case K_CODE:
- if (sc->sc_mode != *(int *)arg) {
- if ((sc->sc_flags & KMI_FLAG_POLLING) == 0)
- kmi_clear_state(kbd);
- sc->sc_mode = *(int *)arg;
- }
- break;
- default:
- return (EINVAL);
- }
- break;
-
- case KDGETLED: /* get keyboard LED */
- *(int *)arg = KBD_LED_VAL(kbd);
- break;
-#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
- defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
- case _IO('K', 66):
- ival = IOCPARM_IVAL(arg);
- arg = (caddr_t)&ival;
- /* FALLTHROUGH */
-#endif
- case KDSETLED: /* set keyboard LED */
- /* NOTE: lock key state in "sc_state" won't be changed */
- if (*(int *)arg & ~LOCK_MASK)
- return (EINVAL);
-
- i = *(int *)arg;
-
- /* replace CAPS LED with ALTGR LED for ALTGR keyboards */
- if (sc->sc_mode == K_XLATE &&
- kbd->kb_keymap->n_keys > ALTGR_OFFSET) {
- if (i & ALKED)
- i |= CLKED;
- else
- i &= ~CLKED;
- }
- if (KBD_HAS_DEVICE(kbd))
- kmi_set_leds(sc, i);
-
- KBD_LED_VAL(kbd) = *(int *)arg;
- break;
- case KDGKBSTATE: /* get lock key state */
- *(int *)arg = sc->sc_state & LOCK_MASK;
- break;
-#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
- defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
- case _IO('K', 20):
- ival = IOCPARM_IVAL(arg);
- arg = (caddr_t)&ival;
- /* FALLTHROUGH */
-#endif
- case KDSKBSTATE: /* set lock key state */
- if (*(int *)arg & ~LOCK_MASK) {
- return (EINVAL);
- }
- sc->sc_state &= ~LOCK_MASK;
- sc->sc_state |= *(int *)arg;
-
- /* set LEDs and quit */
- return (kmi_ioctl(kbd, KDSETLED, arg));
-
- case KDSETREPEAT: /* set keyboard repeat rate (new
- * interface) */
- if (!KBD_HAS_DEVICE(kbd)) {
- return (0);
- }
- if (((int *)arg)[1] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 200) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)arg)[0];
- kbd->kb_delay2 = ((int *)arg)[1];
- return (0);
-
-#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
- defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
- case _IO('K', 67):
- ival = IOCPARM_IVAL(arg);
- arg = (caddr_t)&ival;
- /* FALLTHROUGH */
-#endif
- case KDSETRAD: /* set keyboard repeat rate (old
- * interface) */
- return (kmi_set_typematic(kbd, *(int *)arg));
-
- case PIO_KEYMAP: /* set keyboard translation table */
- case OPIO_KEYMAP: /* set keyboard translation table
- * (compat) */
- case PIO_KEYMAPENT: /* set keyboard translation table
- * entry */
- case PIO_DEADKEYMAP: /* set accent key translation table */
- sc->sc_accents = 0;
- /* FALLTHROUGH */
- default:
- return (genkbd_commonioctl(kbd, cmd, arg));
- }
-
- return (0);
-}
-
-static int
-kmi_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
-{
- int result;
-
- /*
- * XXX KDGKBSTATE, KDSKBSTATE and KDSETLED can be called from any
- * context where printf(9) can be called, which among other things
- * includes interrupt filters and threads with any kinds of locks
- * already held. For this reason it would be dangerous to acquire
- * the Giant here unconditionally. On the other hand we have to
- * have it to handle the ioctl.
- * So we make our best effort to auto-detect whether we can grab
- * the Giant or not. Blame syscons(4) for this.
- */
- switch (cmd) {
- case KDGKBSTATE:
- case KDSKBSTATE:
- case KDSETLED:
- if (!mtx_owned(&Giant) && !SCHEDULER_STOPPED())
- return (EDEADLK); /* best I could come up with */
- /* FALLTHROUGH */
- default:
- KMI_LOCK();
- result = kmi_ioctl_locked(kbd, cmd, arg);
- KMI_UNLOCK();
- return (result);
- }
-}
-
-/* clear the internal state of the keyboard */
-static void
-kmi_clear_state(keyboard_t *kbd)
-{
- struct kmi_softc *sc = kbd->kb_data;
-
- KMI_CTX_LOCK_ASSERT();
-
- sc->sc_flags &= ~(KMI_FLAG_COMPOSE | KMI_FLAG_POLLING);
- sc->sc_state &= LOCK_MASK; /* preserve locking key state */
- sc->sc_accents = 0;
-}
-
-/* save the internal state, not used */
-static int
-kmi_get_state(keyboard_t *kbd, void *buf, size_t len)
-{
- return (len == 0) ? 1 : -1;
-}
-
-/* set the internal state, not used */
-static int
-kmi_set_state(keyboard_t *kbd, void *buf, size_t len)
-{
- return (EINVAL);
-}
-
-static int
-kmi_poll(keyboard_t *kbd, int on)
-{
*** 2348 LINES SKIPPED ***
More information about the dev-commits-src-main
mailing list