diff --git a/doc/components.txt b/doc/components.txt index fc86732aae..abd70b2ede 100644 --- a/doc/components.txt +++ b/doc/components.txt @@ -162,10 +162,6 @@ capture-session and event-session interfaces respectively. :_dde_linux/src/drivers/usb_hid/_: USB Human Interface Device driver using the USB session interface. -:_os/src/drivers/usb_block/_: - USB storage driver that uses the USB session interface and provides - a block-session interface. - Timer drivers ============= @@ -220,11 +216,6 @@ _os/include/block_session/_. :_os/src/drivers/sd_card/spec/rpi/_: Driver for SD-cards connected to the Raspberry Pi. -:_dde_linux/src/drivers/usb/_: - USB driver that makes USB storage devices available as block sessions. - For an example of using this driver, refer to the run script at - _dde_linux/run/usb_storage.run_. - :_os/src/drivers/ahci/_: Driver for SATA disks and CD-ROMs on x86 PCs. @@ -232,7 +223,8 @@ _os/include/block_session/_. Driver for NVMe block devices on x86 PCs. :_os/src/drivers/usb_block/_: - USB Mass Storage Bulk-Only driver using the USB session interface. + USB Mass Storage Bulk-Only driver using the USB session interface and provides + a block-session interface. Network interface drivers @@ -257,8 +249,8 @@ defined at _os/include/nic_session/_. The wifi_drv component is a port of the Linux mac802.11 stack, including the iwlwifi driver. It enables the use of Intel Wireless 6xxx and 7xxx cards. -:_dde_linux/src/drivers/usb/_: - For the OMAP4 platform, the USB driver contains the networking driver. +:_dde_linux/src/drivers/usb_net/_: + USB network driver using the USB session interface. :_dde_linux/src/drivers/nic/fec/_: Driver for ethernet NICs of the i.MX SoC family. diff --git a/repos/dde_linux/README b/repos/dde_linux/README index bc38568bf4..51381b0b8e 100644 --- a/repos/dde_linux/README +++ b/repos/dde_linux/README @@ -3,174 +3,27 @@ Device drivers ported from the Linux kernel USB ### -Controller configuration -~~~~~~~~~~~~~~~~~~~~~~~~ +Host controller +~~~~~~~~~~~~~~~ -The driver can be started using different or all USB controller types a platform -offers (USB 1.0/2.0/3.0). Note that not all controllers are supported by all -platforms. Controllers can be enabled as attribute in the config node of the -driver. Supported attributes are: 'uhci', 'ohci', 'ehci', and 'xhci'. +The driver will start all USB controller types a platform offers. - -Configuration snippet to enable UHCI and EHCI - -! - -BIOS Handoff -~~~~~~~~~~~~ - -Per default the USB driver performs a hand off of the USB controller from the -BIOS, since it still may access the controller when booting, for example, from -a USB device. The BIOS hand off induces the execution of BIOS/SMM USB driver -code and potentially DMA operations. Unfortunately, some ACPI tables report -wrong RMRR information, which implicates IOMMU faults on illegal DMA -operations and consequently the hand off may fail after noticeably long -timeouts. Therefore, the hand off can be disabled in the USB driver -configuration like follows. - -! +Please consult repos/dde_linux/drivers/usb_host/README for a description. HID ~~~ -Supports keyboard and mouse. A run script can be found under 'run/usb_hid.run'. - -Configuration snippet: - -! -! -! -! -! -! - -With '' config node in place, the USB driver requests an "Event" session -for reporting input events. - -Note: It has been observed that certain 1.0 versions of Qemu do not generate -mouse interrupts. The mouse driver should work correctly on Qemu 1.0.93 and -above. - -HID - Touchscreen support -~~~~~~~~~~~~~~~~~~~~~~~~~ - -Touchscreen absolute coordinates must be calibrated (e.g. re-calculated) to -screen absolute coordinates. The screen resolution is not determined -automatically by the USB driver, but can be configured as sub node of the -hid xml tag: - -!... -! -! -! -!... - -If a touchscreen is multi-touch-capable than the multitouch attribute gears -which type of Genode input events are generated. If set to 'no' (default) -than absolute events are generated and no multitouch events. If set to 'yes' -solely multitouch events are generated. +Please consult repos/dde_linux/drivers/usb_hid/README for a description. Storage ~~~~~~~ -Currently supports one USB storage device. Hot plugging has not been tested. A -run script can be found under 'run/usb_storage.run'. - -Configuration snippet: - -! -! -! -! -! - +Please consult repos/os/src/drivers/usb_block/README for a description. Network (Nic) ~~~~~~~~~~~~~ -Configuration snippet: - -! -! -! -! -! -! -! -! -! -! - -Please observe that this setup starts the HID and Nic service at the same time. -Also there is the 'mac' attribute where one can specify the hardware address of -the network interface. This is necessary in case the EEPROM of the network card -cannot be accessed via the host controller making it impossible to retrieve the -devices hardware address. If this is the case and no 'mac' attribute is given a -fallback address will be assigned to the network device. Note that the fallback -address will always be the same. - - -RAW -~~~ - -Allows raw access to USB devices via the 'Usb' session interface. - -Configuration snippet: - -! -! -! -! -! -! -! -! -! - -The optional 'devices' report lists the connected devices and gets updated -when devices are added or removed. - -Example report: - -! -! -! -! -! -! -! -! -! -! - -For every device a unique identifier is generated that is used to access the -USB device. Only devices that have a valid policy configured at the USB driver -can be accessed by a client. The following configuration allows 'comp1' to -access the device 'usb-1-6': - -! -! -! -! -! -! -! -! -! -! - -In addition to the mandatory 'label' attribute the policy node also -contains optional attribute tuples of which at least one has to be present. -The 'vendor_id' and 'product_id' tuple selects a device regardless of its -location on the USB bus and is mostly used in static configurations. The -'bus' and 'dev' tuple selects a specific device via its bus locations and -device address. It is mostly used in dynamic configurations because the device -address is not fixed and may change every time the same device is plugged in. - -The configuration of the USB driver can be changed at runtime to satisfy -dynamic configurations or rather policies when using the 'Usb' session -interface. - +Please consolut repos/dde_linux/src/drivers/usb_net/README for a description. LXIP #### diff --git a/repos/dde_linux/lib/import/import-usb_include.mk b/repos/dde_linux/lib/import/import-usb_include.mk deleted file mode 100644 index ca354c0636..0000000000 --- a/repos/dde_linux/lib/import/import-usb_include.mk +++ /dev/null @@ -1,16 +0,0 @@ -USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/lib/usb - -LIB_DIR := $(REP_DIR)/src/drivers/usb -LIB_INC_DIR := $(LIB_DIR)/include - -include $(call select_from_repositories,lib/import/import-usb_arch_include.mk) - -# -# The order of include-search directories is important, we need to look into -# 'contrib' before falling back to our custom 'lx_emul.h' header. -# -INC_DIR += $(LIB_INC_DIR) -INC_DIR += $(ARCH_SRC_INC_DIR) -INC_DIR += $(USB_CONTRIB_DIR)/include -INC_DIR += $(USB_CONTRIB_DIR)/drivers/usb/core -INC_DIR += $(LIB_CACHE_DIR)/usb_include/include/include/include diff --git a/repos/dde_linux/lib/mk/usb_include.mk b/repos/dde_linux/lib/mk/usb_include.mk deleted file mode 100644 index c707e23115..0000000000 --- a/repos/dde_linux/lib/mk/usb_include.mk +++ /dev/null @@ -1,39 +0,0 @@ -ifeq ($(called_from_lib_mk),yes) - -USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/lib/usb -LX_EMUL_H := $(REP_DIR)/src/drivers/usb/include/lx_emul.h - -# -# Determine the header files included by the contrib code. For each -# of these header files we create a symlink to 'lx_emul.h'. -# -SCAN_DIRS := $(addprefix $(USB_CONTRIB_DIR)/include/, asm-generic linux scsi uapi) \ - $(addprefix $(USB_CONTRIB_DIR)/, drivers lib) -GEN_INCLUDES := $(shell grep -rIh "^\#include .*\/" $(SCAN_DIRS) |\ - sed "s/^\#include [^<\"]*[<\"]\([^>\"]*\)[>\"].*/\1/" |\ - sort | uniq) -# -# Filter out original Linux headers that exist in the contrib directory -# -NO_GEN_INCLUDES := $(shell cd $(USB_CONTRIB_DIR)/; find include -name "*.h" |\ - sed "s/.\///" | sed "s/.*include\///") -GEN_INCLUDES := $(filter-out $(NO_GEN_INCLUDES),$(GEN_INCLUDES)) - -# -# Put Linux headers in 'GEN_INC' dir, since some include use "../../" paths use -# three level include hierarchy -# -GEN_INC := $(shell pwd)/include/include/include -GEN_INCLUDES := $(addprefix $(GEN_INC)/,$(GEN_INCLUDES)) - -all: $(GEN_INCLUDES) - -$(GEN_INCLUDES): - $(VERBOSE)mkdir -p $(dir $@) - $(VERBOSE)ln -s $(LX_EMUL_H) $@ - -endif - -# vi: set ft=make : - -CC_CXX_WARN_STRICT = diff --git a/repos/dde_linux/patches/usb_ax88179.patch b/repos/dde_linux/patches/usb_ax88179.patch deleted file mode 100644 index f788233d00..0000000000 --- a/repos/dde_linux/patches/usb_ax88179.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c -index e6338c1..b768fc8 100644 ---- a/drivers/net/usb/ax88179_178a.c -+++ b/drivers/net/usb/ax88179_178a.c -@@ -1266,6 +1266,7 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) - dev->net->netdev_ops = &ax88179_netdev_ops; - dev->net->ethtool_ops = &ax88179_ethtool_ops; - dev->net->needed_headroom = 8; -+ dev->net->net_ip_align = 1; - - /* Initialize MII structure */ - dev->mii.dev = dev->net; diff --git a/repos/dde_linux/patches/usb_csum.patch b/repos/dde_linux/patches/usb_csum.patch deleted file mode 100644 index b43ce6a54f..0000000000 --- a/repos/dde_linux/patches/usb_csum.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c -index 66b3ab9..a17f054 100644 ---- a/drivers/net/usb/smsc95xx.c -+++ b/drivers/net/usb/smsc95xx.c -@@ -1730,7 +1730,13 @@ static int smsc95xx_reset_resume(struct usb_interface *intf) - - static void smsc95xx_rx_csum_offload(struct sk_buff *skb) - { -- skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2); -+ /* -+ * Use bytewise access to avoid alignment issues on packets that have none -+ * aligned sizes -+ */ -+ char *tail = skb_tail_pointer(skb); -+ skb->csum = (*(tail - 2) << 8) | *(tail - 1); -+ - skb->ip_summed = CHECKSUM_COMPLETE; - skb_trim(skb, skb->len - 2); - } diff --git a/repos/dde_linux/patches/usb_evdev.patch b/repos/dde_linux/patches/usb_evdev.patch deleted file mode 100644 index 403497c22c..0000000000 --- a/repos/dde_linux/patches/usb_evdev.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c -index e9ae3d5..edd0b4f 100644 ---- a/drivers/input/evdev.c -+++ b/drivers/input/evdev.c -@@ -1425,6 +1425,9 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, - if (error) - goto err_cleanup_evdev; - -+ evdev_open_device(evdev); -+ dev_info(evdev, "%s\n", dev->name); -+ - return 0; - - err_cleanup_evdev: -@@ -1457,8 +1460,7 @@ static const struct input_device_id evdev_ids[] = { - MODULE_DEVICE_TABLE(input, evdev_ids); - - static struct input_handler evdev_handler = { -- .event = evdev_event, -- .events = evdev_events, -+ .event = genode_evdev_event, - .connect = evdev_connect, - .disconnect = evdev_disconnect, - .legacy_minors = true, diff --git a/repos/dde_linux/patches/usb_input_mt.patch b/repos/dde_linux/patches/usb_input_mt.patch deleted file mode 100644 index 3ba83d7bc3..0000000000 --- a/repos/dde_linux/patches/usb_input_mt.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/drivers/input/input-mt.c -+++ b/drivers/input/input-mt.c -@@ -217,10 +217,6 @@ - count++; - } - -- input_event(dev, EV_KEY, BTN_TOUCH, count > 0); -- if (use_count) -- input_mt_report_finger_count(dev, count); -- - if (oldest) { - int x = input_mt_get_value(oldest, ABS_MT_POSITION_X); - int y = input_mt_get_value(oldest, ABS_MT_POSITION_Y); -@@ -236,6 +232,10 @@ - if (test_bit(ABS_MT_PRESSURE, dev->absbit)) - input_event(dev, EV_ABS, ABS_PRESSURE, 0); - } -+ -+ input_event(dev, EV_KEY, BTN_TOUCH, count > 0); -+ if (use_count) -+ input_mt_report_finger_count(dev, count); - } - EXPORT_SYMBOL(input_mt_report_pointer_emulation); - diff --git a/repos/dde_linux/patches/usb_mem.patch b/repos/dde_linux/patches/usb_mem.patch deleted file mode 100644 index f0c31f6018..0000000000 --- a/repos/dde_linux/patches/usb_mem.patch +++ /dev/null @@ -1,327 +0,0 @@ -commit 91eb4a3e68978feca81f6a5bc31cfcd7c683d628 -Author: Sebastian Sumpf -Date: Tue Mar 15 09:59:11 2016 +0100 - - mem - -diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c -index 5dd426f..6b4294a 100644 ---- a/drivers/hid/usbhid/hid-core.c -+++ b/drivers/hid/usbhid/hid-core.c -@@ -841,7 +841,7 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) - &usbhid->inbuf_dma); - usbhid->outbuf = usb_alloc_coherent(dev, usbhid->bufsize, GFP_KERNEL, - &usbhid->outbuf_dma); -- usbhid->cr = kmalloc(sizeof(*usbhid->cr), GFP_KERNEL); -+ usbhid->cr = kmalloc(sizeof(*usbhid->cr), GFP_LX_DMA); - usbhid->ctrlbuf = usb_alloc_coherent(dev, usbhid->bufsize, GFP_KERNEL, - &usbhid->ctrlbuf_dma); - if (!usbhid->inbuf || !usbhid->outbuf || !usbhid->cr || -@@ -1013,7 +1013,7 @@ static int usbhid_parse(struct hid_device *hid) - return -EINVAL; - } - -- if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) { -+ if (!(rdesc = kmalloc(rsize, GFP_LX_DMA))) { - dbg_hid("couldn't allocate rdesc memory\n"); - return -ENOMEM; - } -diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c -index 0744bf2..6237370 100644 ---- a/drivers/net/usb/usbnet.c -+++ b/drivers/net/usb/usbnet.c -@@ -229,7 +229,7 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf) - period = max ((int) dev->status->desc.bInterval, - (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); - -- buf = kmalloc (maxp, GFP_KERNEL); -+ buf = kmalloc (maxp, GFP_LX_DMA); - if (buf) { - dev->interrupt = usb_alloc_urb (0, GFP_KERNEL); - if (!dev->interrupt) { -@@ -1916,7 +1916,7 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, - cmd, reqtype, value, index, size); - - if (data) { -- buf = kmalloc(size, GFP_KERNEL); -+ buf = kmalloc(size, GFP_LX_DMA); - if (!buf) - goto out; - } -@@ -1943,7 +1943,7 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, - cmd, reqtype, value, index, size); - - if (data) { -- buf = kmemdup(data, size, GFP_KERNEL); -+ buf = kmemdup(data, size, GFP_LX_DMA); - if (!buf) - goto out; - } -@@ -2192,7 +2192,7 @@ int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype, - } - - if (data) { -- buf = kmemdup(data, size, GFP_ATOMIC); -+ buf = kmemdup(data, size, GFP_LX_DMA); - if (!buf) { - netdev_err(dev->net, "Error allocating buffer" - " in %s!\n", __func__); -@@ -2200,7 +2200,7 @@ int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype, - } - } - -- req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); -+ req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_LX_DMA); - if (!req) - goto fail_free_buf; - -diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c -index 5050760..9ac55f9 100644 ---- a/drivers/usb/core/config.c -+++ b/drivers/usb/core/config.c -@@ -695,7 +695,7 @@ int usb_get_configuration(struct usb_device *dev) - if (!dev->rawdescriptors) - goto err2; - -- desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL); -+ desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_LX_DMA); - if (!desc) - goto err2; - -@@ -724,7 +724,7 @@ int usb_get_configuration(struct usb_device *dev) - USB_DT_CONFIG_SIZE); - - /* Now that we know the length, get the whole thing */ -- bigbuffer = kmalloc(length, GFP_KERNEL); -+ bigbuffer = kmalloc(length, GFP_LX_DMA); - if (!bigbuffer) { - result = -ENOMEM; - goto err; -@@ -786,7 +786,7 @@ int usb_get_bos_descriptor(struct usb_device *dev) - int length, total_len, num, i; - int ret; - -- bos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_KERNEL); -+ bos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_LX_DMA); - if (!bos) - return -ENOMEM; - -@@ -812,7 +812,7 @@ int usb_get_bos_descriptor(struct usb_device *dev) - return -ENOMEM; - - /* Now let's get the whole BOS descriptor set */ -- buffer = kzalloc(total_len, GFP_KERNEL); -+ buffer = kzalloc(total_len, GFP_LX_DMA); - if (!buffer) { - ret = -ENOMEM; - goto err; -diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c -index 1560f3f..54e99b5 100644 ---- a/drivers/usb/core/hub.c -+++ b/drivers/usb/core/hub.c -@@ -1365,20 +1365,20 @@ static int hub_configure(struct usb_hub *hub, - unsigned full_load; - unsigned maxchild; - -- hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); -+ hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_LX_DMA); - if (!hub->buffer) { - ret = -ENOMEM; - goto fail; - } - -- hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL); -+ hub->status = kmalloc(sizeof(*hub->status), GFP_LX_DMA); - if (!hub->status) { - ret = -ENOMEM; - goto fail; - } - mutex_init(&hub->status_mutex); - -- hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); -+ hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_LX_DMA); - if (!hub->descriptor) { - ret = -ENOMEM; - goto fail; -@@ -4586,7 +4586,7 @@ check_highspeed(struct usb_hub *hub, struct usb_device *udev, int port1) - if (udev->quirks & USB_QUIRK_DEVICE_QUALIFIER) - return; - -- qual = kmalloc(sizeof *qual, GFP_KERNEL); -+ qual = kmalloc(sizeof *qual, GFP_LX_DMA); - if (qual == NULL) - return; - -diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c -index 8e641b5..5807f68 100644 ---- a/drivers/usb/core/message.c -+++ b/drivers/usb/core/message.c -@@ -942,7 +942,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size) - int usb_get_status(struct usb_device *dev, int type, int target, void *data) - { - int ret; -- __le16 *status = kmalloc(sizeof(*status), GFP_KERNEL); -+ __le16 *status = kmalloc(sizeof(*status), GFP_LX_DMA); - - if (!status) - return -ENOMEM; -diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c -index b6205fa..99cae0f 100644 ---- a/drivers/usb/host/ehci-mem.c -+++ b/drivers/usb/host/ehci-mem.c -@@ -82,7 +82,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags) - struct ehci_qh *qh; - dma_addr_t dma; - -- qh = kzalloc(sizeof *qh, GFP_ATOMIC); -+ qh = kzalloc(sizeof *qh, GFP_LX_DMA); - if (!qh) - goto done; - qh->hw = (struct ehci_qh_hw *) -diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c -index 776d59c..e32db7b 100644 ---- a/drivers/usb/host/xhci.c -+++ b/drivers/usb/host/xhci.c -@@ -1354,7 +1354,7 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) - size = 1; - - urb_priv = kzalloc(sizeof(struct urb_priv) + -- size * sizeof(struct xhci_td *), mem_flags); -+ size * sizeof(struct xhci_td *), GFP_LX_DMA); - if (!urb_priv) - return -ENOMEM; - -diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c -index 43576ed..2b13b4e 100644 ---- a/drivers/usb/storage/usb.c -+++ b/drivers/usb/storage/usb.c -@@ -450,7 +450,7 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf) - usb_set_intfdata(intf, us); - - /* Allocate the control/setup and DMA-mapped buffers */ -- us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL); -+ us->cr = kmalloc(sizeof(*us->cr), GFP_LX_DMA); - if (!us->cr) - return -ENOMEM; - ---- a/drivers/hid/hid-multitouch.c -+++ b/drivers/hid/hid-multitouch.c -@@ -325,7 +325,7 @@ - if (td->mtclass.name != MT_CLS_WIN_8) - return; - -- buf = hid_alloc_report_buf(report, GFP_KERNEL); -+ buf = hid_alloc_report_buf(report, GFP_LX_DMA); - if (!buf) - return; - -@@ -912,7 +912,7 @@ - if (r) { - if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { - report_len = hid_report_len(r); -- buf = hid_alloc_report_buf(r, GFP_KERNEL); -+ buf = hid_alloc_report_buf(r, GFP_LX_DMA); - if (!buf) { - hid_err(hdev, "failed to allocate buffer for report\n"); - return; -@@ -1043,7 +1043,7 @@ - if (suffix) { - name = devm_kzalloc(&hi->input->dev, - strlen(hdev->name) + strlen(suffix) + 2, -- GFP_KERNEL); -+ GFP_LX_DMA); - if (name) { - sprintf(name, "%s %s", hdev->name, suffix); - hi->input->name = name; -@@ -1096,7 +1096,7 @@ - */ - hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; - -- td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); -+ td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_LX_DMA); - if (!td) { - dev_err(&hdev->dev, "cannot allocate multitouch data\n"); - return -ENOMEM; -@@ -1110,7 +1110,7 @@ - hid_set_drvdata(hdev, td); - - td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields), -- GFP_KERNEL); -+ GFP_LX_DMA); - if (!td->fields) { - dev_err(&hdev->dev, "cannot allocate multitouch fields data\n"); - return -ENOMEM; ---- a/drivers/hid/wacom_sys.c -+++ b/drivers/hid/wacom_sys.c -@@ -124,7 +124,7 @@ - /* leave touch_max as is if predefined */ - if (!features->touch_max) { - /* read manually */ -- data = kzalloc(2, GFP_KERNEL); -+ data = kzalloc(2, GFP_LX_DMA); - if (!data) - break; - data[0] = field->report->id; -@@ -328,7 +328,7 @@ - unsigned char *rep_data; - int error = -ENOMEM, limit = 0; - -- rep_data = kzalloc(length, GFP_KERNEL); -+ rep_data = kzalloc(length, GFP_LX_DMA); - if (!rep_data) - return error; - -@@ -530,7 +530,7 @@ - - data = wacom_get_hdev_data(hdev); - if (!data) { -- data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL); -+ data = kzalloc(sizeof(struct wacom_hdev_data), GFP_LX_DMA); - if (!data) { - retval = -ENOMEM; - goto out; -@@ -595,7 +595,7 @@ - report_id = WAC_CMD_WL_LED_CONTROL; - buf_size = 13; - } -- buf = kzalloc(buf_size, GFP_KERNEL); -+ buf = kzalloc(buf_size, GFP_LX_DMA); - if (!buf) - return -ENOMEM; - -@@ -648,7 +648,7 @@ - int i, retval; - const unsigned chunk_len = len / 4; /* 4 chunks are needed to be sent */ - -- buf = kzalloc(chunk_len + 3 , GFP_KERNEL); -+ buf = kzalloc(chunk_len + 3 , GFP_LX_DMA); - if (!buf) - return -ENOMEM; - -@@ -1176,7 +1176,7 @@ - - wacom_wac->serial[index] = serial; - -- buf = kzalloc(WAC_REMOTE_SERIAL_MAX_STRLEN, GFP_KERNEL); -+ buf = kzalloc(WAC_REMOTE_SERIAL_MAX_STRLEN, GFP_LX_DMA); - if (!buf) - return -ENOMEM; - snprintf(buf, WAC_REMOTE_SERIAL_MAX_STRLEN, "%d", serial); -@@ -1222,7 +1222,7 @@ - unsigned char *buf; - int retval; - -- buf = kzalloc(buf_size, GFP_KERNEL); -+ buf = kzalloc(buf_size, GFP_LX_DMA); - if (!buf) - return -ENOMEM; - -@@ -1705,7 +1705,7 @@ - /* hid-core sets this quirk for the boot interface */ - hdev->quirks &= ~HID_QUIRK_NOGET; - -- wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); -+ wacom = kzalloc(sizeof(struct wacom), GFP_LX_DMA); - if (!wacom) - return -ENOMEM; - diff --git a/repos/dde_linux/patches/usb_rndis.patch b/repos/dde_linux/patches/usb_rndis.patch deleted file mode 100644 index 8667e2716c..0000000000 --- a/repos/dde_linux/patches/usb_rndis.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff -Nur a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c ---- a/drivers/net/usb/rndis_host.c -+++ b/drivers/net/usb/rndis_host.c -@@ -318,7 +318,7 @@ - unsigned char *bp; - - /* we can't rely on i/o from stack working, or stack allocation */ -- u.buf = kmalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL); -+ u.buf = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL | GFP_LX_DMA); - if (!u.buf) - return -ENOMEM; - retval = usbnet_generic_cdc_bind(dev, intf); -@@ -475,7 +475,7 @@ - struct rndis_halt *halt; - - /* try to clear any rndis state/activity (no i/o from stack!) */ -- halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL); -+ halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL | GFP_LX_DMA); - if (halt) { - halt->msg_type = cpu_to_le32(RNDIS_MSG_HALT); - halt->msg_len = cpu_to_le32(sizeof *halt); -@@ -573,7 +573,7 @@ - * packets; Linux minimizes wasted bandwidth through tx queues. - */ - fill: -- hdr = (void *) __skb_push(skb, sizeof *hdr); -+ hdr = (void *) skb_push(skb, sizeof *hdr); - memset(hdr, 0, sizeof *hdr); - hdr->msg_type = cpu_to_le32(RNDIS_MSG_PACKET); - hdr->msg_len = cpu_to_le32(skb->len); diff --git a/repos/dde_linux/patches/usb_tv64.patch b/repos/dde_linux/patches/usb_tv64.patch deleted file mode 100644 index 1bf2b2145f..0000000000 --- a/repos/dde_linux/patches/usb_tv64.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/drivers/usb/host/ehci-timer.c b/drivers/usb/host/ehci-timer.c -index 424ac5d..a2afc34 100644 ---- a/drivers/usb/host/ehci-timer.c -+++ b/drivers/usb/host/ehci-timer.c -@@ -422,7 +422,7 @@ static enum hrtimer_restart ehci_hrtimer_func(struct hrtimer *t) - */ - now = ktime_get(); - for_each_set_bit(e, &events, EHCI_HRTIMER_NUM_EVENTS) { -- if (now.tv64 >= ehci->hr_timeouts[e].tv64) -+ if (now >= ehci->hr_timeouts[e]) - event_handlers[e](ehci); - else - ehci_enable_event(ehci, e, false); diff --git a/repos/dde_linux/patches/usb_usbnet.patch b/repos/dde_linux/patches/usb_usbnet.patch deleted file mode 100644 index b18f3ad09c..0000000000 --- a/repos/dde_linux/patches/usb_usbnet.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c -index 6237370..8339402 100644 ---- a/drivers/net/usb/usbnet.c -+++ b/drivers/net/usb/usbnet.c -@@ -64,8 +64,30 @@ - * the equation. - */ - #define MAX_QUEUE_MEMORY (60 * 1518) --#define RX_QLEN(dev) ((dev)->rx_qlen) --#define TX_QLEN(dev) ((dev)->tx_qlen) -+ -+inline unsigned RX_QLEN(struct usbnet *dev) -+{ -+ switch(dev->udev->speed) { -+ case USB_SPEED_HIGH: -+ return MAX_QUEUE_MEMORY/dev->rx_urb_size; -+ case USB_SPEED_SUPER: -+ return 16; -+ default: -+ return 4; -+ } -+} -+ -+inline unsigned TX_QLEN(struct usbnet *dev) -+{ -+ switch(dev->udev->speed) { -+ case USB_SPEED_HIGH: -+ return MAX_QUEUE_MEMORY/dev->hard_mtu; -+ case USB_SPEED_SUPER: -+ return 16; -+ default: -+ return 4; -+ } -+} - - // reawaken network queue this soon after stopping; else watchdog barks - #define TX_TIMEOUT_JIFFIES (5*HZ) diff --git a/repos/dde_linux/ports/dde_linux.hash b/repos/dde_linux/ports/dde_linux.hash index 1f59075817..862241b722 100644 --- a/repos/dde_linux/ports/dde_linux.hash +++ b/repos/dde_linux/ports/dde_linux.hash @@ -1 +1 @@ -6f2e873679a79e8c85bdf62c2f81910b357f8abe +c2dc5da56111d6a1734458679176722832b10207 diff --git a/repos/dde_linux/ports/dde_linux.port b/repos/dde_linux/ports/dde_linux.port index 014e31a1d4..f55d7a563e 100644 --- a/repos/dde_linux/ports/dde_linux.port +++ b/repos/dde_linux/ports/dde_linux.port @@ -1,6 +1,6 @@ LICENSE := GPLv2 VERSION := 2 -DOWNLOADS := dwc_otg.git usb.archive intel_fb.archive lxip.archive \ +DOWNLOADS := intel_fb.archive lxip.archive \ wifi.archive fec.archive libnl.archive wpa_supplicant.git \ fw.archive usb_host.archive dwc_otg_host.git usb_hid.archive \ usb_modem.archive usb_net.archive imx8_fb.archive @@ -18,21 +18,9 @@ YACC = bison # The git checkout checks for the existence of SRC_DIR, which is created by the # Linux extraction, therefore make sure to checkout the GIT sources first. # -usb.archive: dwc_otg.git usb_host.archive: dwc_otg_host.git -# -# USB -# -SRC_DIR_USB := src/lib/usb -VERSION_USB := 4.4.3 -URL(usb) := https://www.kernel.org/pub/linux/kernel/v4.x/linux-$(VERSION_USB).tar.xz -SHA(usb) := 0b379cb19bbd7e38fc5a9a000ea927db55cce519a7400ec7fa705c581a6491dd -DIR(usb) := $(SRC_DIR_USB) -TAR_OPT(usb) := --strip-components=1 --files-from - < <(sed 's/-x.x.x/-$(VERSION_USB)/g' $(REP_DIR)/usb.list) -HASH_INPUT += $(REP_DIR)/usb.list - # # USB host controller # @@ -71,10 +59,6 @@ HASH_INPUT += $(REP_DIR)/usb_modem.list # # Raspberry Pi USB controller # -URL(dwc_otg) := https://github.com/ssumpf/dwc_otg.git -REV(dwc_otg) := r3 -DIR(dwc_otg) := $(SRC_DIR_USB)/drivers/usb/host/dwc_otg - URL(dwc_otg_host) := https://github.com/cproc/dwc_otg.git REV(dwc_otg_host) := r5 DIR(dwc_otg_host) := $(SRC_DIR_USB_HOST)/drivers/usb/host @@ -194,17 +178,6 @@ PATCH_OPT(patches/libnl.patch) := -p1 -d ${DIR(libnl)} # WPA supplicant PATCH_OPT(patches/wpa_supplicant.patch) := -p1 -d ${DIR(wpa_supplicant)} -# USB -USB_OPT = -p1 -d$(SRC_DIR_USB) -PATCH_OPT(patches/usb_ax88179.patch) := $(USB_OPT) -PATCH_OPT(patches/usb_csum.patch) := $(USB_OPT) -PATCH_OPT(patches/usb_evdev.patch) := $(USB_OPT) -PATCH_OPT(patches/usb_input_mt.patch) := $(USB_OPT) -PATCH_OPT(patches/usb_mem.patch) := $(USB_OPT) -PATCH_OPT(patches/usb_usbnet.patch) := $(USB_OPT) -PATCH_OPT(patches/usb_rndis.patch) := $(USB_OPT) -PATCH_OPT(patches/usb_tv64.patch) := $(USB_OPT) - # USB HOST USB_HOST_OPT = -p1 -d$(SRC_DIR_USB_HOST) PATCH_OPT(patches/usb_host_mem.patch) := $(USB_HOST_OPT) diff --git a/repos/dde_linux/recipes/src/usb_drv/content.mk b/repos/dde_linux/recipes/src/usb_drv/content.mk deleted file mode 100644 index 450e82a171..0000000000 --- a/repos/dde_linux/recipes/src/usb_drv/content.mk +++ /dev/null @@ -1,26 +0,0 @@ -LIB_MK := lib/import/import-usb_include.mk lib/mk/usb_include.mk \ - lib/import/import-usb_arch_include.mk \ - $(foreach SPEC,x86_32 x86_64 arm,lib/mk/spec/$(SPEC)/lx_kit_setjmp.mk) - -PORT_DIR := $(call port_dir,$(REP_DIR)/ports/dde_linux) - -MIRROR_FROM_REP_DIR := $(LIB_MK) \ - src/drivers/usb \ - src/include src/lx_kit - -MIRROR_FROM_PORT_DIR := $(shell cd $(PORT_DIR); find src/lib/usb -type f | grep -v ".git") -MIRROR_FROM_PORT_DIR := $(filter-out $(MIRROR_FROM_REP_DIR),$(MIRROR_FROM_PORT_DIR)) - -content: $(MIRROR_FROM_REP_DIR) $(MIRROR_FROM_PORT_DIR) - -$(MIRROR_FROM_REP_DIR): - $(mirror_from_rep_dir) - -$(MIRROR_FROM_PORT_DIR): - mkdir -p $(dir $@) - cp $(PORT_DIR)/$@ $@ - -content: LICENSE -LICENSE: - ( echo "GNU General Public License version 2, see:"; \ - echo "https://www.kernel.org/pub/linux/kernel/COPYING" ) > $@ diff --git a/repos/dde_linux/recipes/src/usb_drv/hash b/repos/dde_linux/recipes/src/usb_drv/hash deleted file mode 100644 index 20694e199c..0000000000 --- a/repos/dde_linux/recipes/src/usb_drv/hash +++ /dev/null @@ -1 +0,0 @@ -2021-05-27 ca37c2f2c35387633aff258015e3bee29ff6109a diff --git a/repos/dde_linux/recipes/src/usb_drv/used_apis b/repos/dde_linux/recipes/src/usb_drv/used_apis deleted file mode 100644 index 797b95b382..0000000000 --- a/repos/dde_linux/recipes/src/usb_drv/used_apis +++ /dev/null @@ -1,12 +0,0 @@ -base -os -nic_session -uplink_session -nic_driver -usb_session -gpio_session -event_session -block_session -platform_session -timer_session -report_session diff --git a/repos/dde_linux/run/usb_hid.run b/repos/dde_linux/run/usb_hid.run deleted file mode 100644 index 9f1311cce9..0000000000 --- a/repos/dde_linux/run/usb_hid.run +++ /dev/null @@ -1,235 +0,0 @@ -# -# USB HID test -# -# By default, the run script runs interactively and reports any received USB -# input events to the console. -# -# When run with the '--autopilot' run option, the run script tests the USB -# input events generated by a 'Pro Micro' microcontroller. -# -# Pro Micro setup instructions -# ---------------------------- -# -# Install prerequisites (example for Xubuntu 16.04): -# -# $ sudo apt-get install gcc-avr avr-libc avrdude -# -# Checkout and build the microcontroller software: -# -# $ git clone https://github.com/cproc/lufa.git -# $ cd lufa -# $ git checkout genode_usb_tests -# $ cd Demos/Device/ClassDriver/KeyboardMouseGenode -# $ make -# -# Connect the 'RST' pin with the 'GND' pin to hold the Pro Micro in the reset -# state. -# -# Connect the Pro Micro to the host PC -# -# Check the device file name with 'dmesg'. If it is not 'ttyACM0', change -# 'AVRDUDE_PORT' in 'makefile' accordingly. -# -# Release the RST/GND pin connection and within the next 8 seconds run: -# -# $ make avrdude -# -# Disconnect the Pro Micro or put it into reset state again to avoid unexpected -# input events on the host PC. -# - -if { [get_cmd_switch --autopilot] && [have_include "power_on/qemu"] } { - puts "Run script does not support autopilot mode on Qemu" - exit 0 -} - -if {![have_board rpi] && ![have_board pc]} { - puts "Run script does not support autopilot mode on this platform" - exit 0 -} - -proc usb_drv_binary { } { - if {[have_board rpi]} { return rpi_usb_drv } - if {[have_board pc]} { return usb_drv } - return no_usb_drv_available -} - -# -# Build -# - -set build_components { - core init timer - drivers/usb - server/event_dump - server/dynamic_rom -} - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -append config { - - - - - - - - - - - - - - - } - -append_platform_drv_config - -append config { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -install_config $config - -# -# Boot modules -# - -# generic modules -set boot_modules { - core ld.lib.so init timer event_dump dynamic_rom -} - -append boot_modules [usb_drv_binary] - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - -append qemu_args " -usb -usbdevice mouse -usbdevice keyboard" -append qemu_args " -device usb-ehci,id=ehci" -append xen_args { usbdevice=\["mouse","keyboard"\] } - -if { [have_include "power_on/qemu"] || ![get_cmd_switch --autopilot] } { run_genode_until forever } - -# autopilot test - -run_genode_until {\[init -\> event_dump\] Input event #0\t} 60 - -# remove everything before the first interesting line -regexp {(\[init -\> event_dump\] Input event #0\t.*)} $output all output - -run_genode_until {\[init -\> event_dump\] Input event #11.*\n} 40 [output_spawn_id] - -# pay only attention to the output of init and its children -grep_output {^\[init } - -unify_output { number [0-9]+} "" -unify_output {(?n)on usb-.*$} "" -unify_output {(?n)using .*$} "" -unify_output {(?n)^.*__wait_event.*$} "" -unify_output {(?n)^.*Failed to submit URB.*$} "" -unify_output {(?n)^.*dev_warn.*$} "" -filter_out_color_escape_sequences -trim_lines - -compare_output_to { -[init -> event_dump] Input event #0 PRESS KEY_X 65534 key count: 1 -[init -> event_dump] Input event #1 RELEASE KEY_X key count: 0 -[init -> event_dump] Input event #2 PRESS BTN_LEFT 65534 key count: 1 -[init -> event_dump] Input event #3 REL_MOTION -1+0 key count: 1 -[init -> event_dump] Input event #4 REL_MOTION +0+1 key count: 1 -[init -> event_dump] Input event #5 RELEASE BTN_LEFT key count: 0 -[init -> usb_drv] dev_info: USB disconnect, device -[init -> usb_drv] dev_info: new full-speed USB device -[init -> usb_drv] dev_info: D L -[init -> usb_drv] dev_info: input: USB HID v1.11 Keyboard [D L] -[init -> usb_drv] dev_info: D L -[init -> usb_drv] dev_info: input: USB HID v1.11 Mouse [D L] -[init -> event_dump] Input event #6 PRESS KEY_X 65534 key count: 1 -[init -> event_dump] Input event #7 RELEASE KEY_X key count: 0 -[init -> event_dump] Input event #8 PRESS BTN_LEFT 65534 key count: 1 -[init -> event_dump] Input event #9 REL_MOTION -1+0 key count: 1 -[init -> event_dump] Input event #10 REL_MOTION +0+1 key count: 1 -[init -> event_dump] Input event #11 RELEASE BTN_LEFT key count: 0 -} diff --git a/repos/dde_linux/run/usb_hid_raw.run b/repos/dde_linux/run/usb_hid_raw.run index ff3bd368d5..4d113b1a3e 100644 --- a/repos/dde_linux/run/usb_hid_raw.run +++ b/repos/dde_linux/run/usb_hid_raw.run @@ -201,9 +201,8 @@ append config { - } -append config "" -append config { + + diff --git a/repos/dde_linux/run/usb_hid_reconnect.run b/repos/dde_linux/run/usb_hid_reconnect.run index fd3062820c..c82109d982 100644 --- a/repos/dde_linux/run/usb_hid_reconnect.run +++ b/repos/dde_linux/run/usb_hid_reconnect.run @@ -26,7 +26,8 @@ if {[get_cmd_switch --autopilot] && ![have_spec x86_64]} { set build_components { core init timer - drivers/usb + drivers/usb_host + drivers/usb_hid server/event_dump server/dynamic_rom } @@ -67,17 +68,23 @@ append config { - + + + + + + + + + + - - + + + + - - - @@ -87,7 +94,20 @@ append config { - + + + + + + + + + + + + + + @@ -138,8 +158,10 @@ install_config $config # generic modules set boot_modules { - core ld.lib.so init timer usb_drv event_dump dynamic_rom + core ld.lib.so init timer event_dump dynamic_rom + usb_hid_drv } +append boot_modules [usb_host_drv_binary] append_platform_drv_boot_modules diff --git a/repos/dde_linux/run/usb_rndis.run b/repos/dde_linux/run/usb_rndis.run index 8bdf1d3ae5..18a7211584 100644 --- a/repos/dde_linux/run/usb_rndis.run +++ b/repos/dde_linux/run/usb_rndis.run @@ -12,10 +12,12 @@ assert_spec x86 set build_components { core init timer - drivers/usb + drivers/usb_host + drivers/usb_net server/tcp_terminal test/terminal_echo lib/vfs/lwip + lib/vfs/pipe server/nic_router } @@ -30,7 +32,8 @@ create_boot_directory # Generate config # -set config { +set config "" +append config { @@ -52,13 +55,24 @@ set config { - + + - - + + + + + + + + + + + + @@ -68,7 +82,7 @@ set config { - + @@ -87,7 +101,7 @@ set config { - + @@ -105,8 +119,7 @@ set config { - - } + } append_platform_drv_config @@ -122,13 +135,15 @@ install_config $config # generic modules set boot_modules { - core ld.lib.so init timer usb_drv - libc.lib.so vfs.lib.so lwip_legacy.lib.so + core ld.lib.so init timer + libc.lib.so vfs.lib.so vfs_pipe.lib.so tcp_terminal test-terminal_echo vfs_lwip.lib.so + usb_net_drv nic_router } +append boot_modules [usb_host_drv_binary] append_platform_drv_boot_modules diff --git a/repos/dde_linux/run/usb_storage.run b/repos/dde_linux/run/usb_storage.run deleted file mode 100644 index 2f762dfd80..0000000000 --- a/repos/dde_linux/run/usb_storage.run +++ /dev/null @@ -1,121 +0,0 @@ -# -# \brief Test for using the Block (Storage) service of usb_drv -# \author Christian Prochaska -# \date 2011-06-24 -# - -assert_spec x86 - -# -# Build -# - -set build_components { - core init timer - drivers/usb - test/block/client -} - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -set config { - - - - - - - - - - - - - - - } - -append_platform_drv_config - -append config { - - - - - - - - - - - - - - - -} -install_config $config - -# -# Boot modules -# - -# generic modules -set boot_modules { - core ld.lib.so init timer usb_drv test-block-client -} - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - -# -# Execute test case -# -set disk_image "bin/test.img" -set cmd "dd if=/dev/zero of=$disk_image bs=1024 count=65536" -puts "creating disk image:\n$cmd" -catch { exec sh -c $cmd } - -set cmd "mkfs.vfat -F32 $disk_image" -puts "formating disk image with vfat file system:\$cmd" -catch { exec sh -c $cmd } - -# -# Qemu opts for UHCI -# -#append qemu_args " -nographic -usbdevice disk::$disk_image -boot order=d" - -# -# Qemu opts for EHCI -# -append qemu_args "-drive if=none,id=disk,file=$disk_image" -append qemu_args { \ - -nographic -M pc \ --device usb-ehci,id=ehci \ --device usb-storage,bus=ehci.0,drive=disk \ --boot order=d } - -# -# Qemu opts for XHCI -# -#append qemu_args { \ -# -nographic -M pc \ -#-device nec-usb-xhci,id=xhci \ -#-device usb-storage,bus=xhci.0,drive=disk \ -#-boot order=d } - -run_genode_until {.*child "test-usb" exited with exit value 0.*} 100 - -puts "\nTest succeeded\n" - -# vi: set ft=tcl : diff --git a/repos/dde_linux/run/usb_terminal.run b/repos/dde_linux/run/usb_terminal.run index 1917d98b13..b64154cc4a 100644 --- a/repos/dde_linux/run/usb_terminal.run +++ b/repos/dde_linux/run/usb_terminal.run @@ -17,7 +17,7 @@ if {[have_include power_on/qemu]} { # set build_components { core init timer - drivers/usb + drivers/usb_host server/usb_terminal test/terminal_echo } @@ -57,13 +57,12 @@ append config { - + + - - - - + + @@ -83,9 +82,10 @@ install_config $config # generic modules set boot_modules { - core ld.lib.so init timer usb_drv test-terminal_echo + core ld.lib.so init timer test-terminal_echo usb_terminal } +append boot_modules [usb_host_drv_binary] append_platform_drv_boot_modules diff --git a/repos/dde_linux/src/drivers/usb/dummies.c b/repos/dde_linux/src/drivers/usb/dummies.c deleted file mode 100644 index 2650596cb6..0000000000 --- a/repos/dde_linux/src/drivers/usb/dummies.c +++ /dev/null @@ -1,1169 +0,0 @@ -/* - * \brief Dummy functions - * \author Norman Feske - * \author Sebastian sumpf - * \date 2011-01-29 - */ - -/* - * Copyright (C) 2011-2017 Genode Labs GmbH - * Copyright (C) 2014 Ksys Labs LLC - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -/* Linux kernel API */ -#include - -/* Linux includes */ -#include - -#define SKIP_VERBOSE 0 - -#if DEBUG_TRACE -#define TRACE lx_printf("\033[32m%s\033[0m called from %p, not implemented\n", __PRETTY_FUNCTION__, __builtin_return_address(0)) -#else -#define TRACE -#endif -#if SKIP_VERBOSE -#define SKIP lx_printf("\033[34m%s\033[0m: skipped\n", __PRETTY_FUNCTION__) -#else -#define SKIP -#endif - -/****************** - ** linux/slab.h ** - ******************/ - -void *kmalloc_array(size_t n, size_t size, gfp_t flags) { TRACE; return (void *)0xdeadbeaf; } - - -/****************** - ** asm/atomic.h ** - ******************/ - -int atomic_inc_return(atomic_t *v) { TRACE; return 0; } - - -/******************** - ** linux/kernel.h ** - ********************/ - -void might_sleep() { SKIP; } -char *kasprintf(gfp_t gfp, const char *fmt, ...) { TRACE; return NULL; } -int kstrtouint(const char *s, unsigned int base, unsigned int *res) { TRACE; return 0; } -int kstrtoul(const char *s, unsigned int base, unsigned long *res) { TRACE; return 0; } -int kstrtou8(const char *s, unsigned int base, u8 *x) { TRACE; return 1; } -int sprintf(char *buf, const char *fmt, ...) { TRACE; return 0; } -int sscanf(const char *b, const char *s, ...) { TRACE; return 0; } -int scnprintf(char *buf, size_t size, const char *fmt, ...); -int strict_strtoul(const char *s, unsigned int base, unsigned long *res) { TRACE; return 0; } -long simple_strtoul(const char *cp, char **endp, unsigned int base) { TRACE; return 0; } - - -/****************** - ** linux/log2.h ** - ******************/ - -int roundup_pow_of_two(u32 n) { TRACE; return 0; } - - -/******************** - ** linux/printk.h ** - ********************/ - -void print_hex_dump(const char *level, const char *prefix_str, - int prefix_type, int rowsize, int groupsize, - const void *buf, size_t len, bool ascii) { TRACE; } -bool printk_ratelimit() { TRACE; return 0; } -bool printk_ratelimited() { TRACE; return 0; } -bool printk_timed_ratelimit(unsigned long *caller_jiffies, - unsigned int interval_msec) { TRACE; return false; } - - -/********************************** - ** linux/bitops.h, asm/bitops.h ** - **********************************/ - -int ffs(int x) { TRACE; return 0; } - - -/******************** - ** linux/string.h ** - ********************/ - -int memcmp(const void *dst, const void *src, size_t s) { TRACE; return 0; } -char *strcat(char *dest, const char *src) { TRACE; return 0; } -int strncmp(const char *cs, const char *ct, size_t count) { TRACE; return 0; } -char *strncpy(char *dst, const char *src, size_t s) { TRACE; return NULL; } -char *strchr(const char *s, int n) { TRACE; return NULL; } -char *strrchr(const char *s, int n) { TRACE; return NULL; } -char *strsep(char **s,const char *d) { TRACE; return NULL; } -char *kstrdup(const char *s, gfp_t gfp) { TRACE; return 0; } -char *strstr(const char *h, const char *n) { TRACE; return 0; } - - -/******************* - ** linux/ctype.h ** - *******************/ - -int isprint(int v) { TRACE; return 0; } - - -/********************** - ** linux/spinlock.h ** - **********************/ - -void spin_lock(spinlock_t *lock) { SKIP; } -void spin_lock_nested(spinlock_t *lock, int subclass) { TRACE; } -void spin_unlock(spinlock_t *lock) { SKIP; } -void spin_lock_init(spinlock_t *lock) { SKIP; } -void spin_lock_irqsave(spinlock_t *lock, unsigned long flags) { SKIP; } -void spin_lock_irqrestore(spinlock_t *lock, unsigned long flags) { SKIP; } -void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) { SKIP; } -void spin_lock_irq(spinlock_t *lock) { SKIP; } -void spin_unlock_irq(spinlock_t *lock) { SKIP; } -void assert_spin_locked(spinlock_t *lock) { TRACE;} - - - -/******************* - ** linux/mutex.h ** - *******************/ - -int mutex_lock_interruptible(struct mutex *m) { SKIP; return 0; } -void mutex_init (struct mutex *m) { SKIP; } -void mutex_lock (struct mutex *m) { SKIP; } -void mutex_unlock(struct mutex *m) { SKIP; } - - -/******************* - ** linux/rwsem.h ** - *******************/ - -void down_read(struct rw_semaphore *sem) { SKIP; } -void up_read(struct rw_semaphore *sem) { SKIP; } -void down_write(struct rw_semaphore *sem) { SKIP; } -void up_write(struct rw_semaphore *sem) { SKIP; } - - -/********************* - ** linux/lockdep.h ** - *********************/ - -bool lockdep_is_held(void *l) { TRACE; return 1; } - - -/******************** - ** linux/random.h ** - ********************/ - -void add_device_randomness(const void *buf, unsigned int size) { TRACE; } - - -/******************* - ** linux/ktime.h ** - *******************/ - -#define KTIME_RET ({TRACE; ktime_t t = { 0 }; return t;}) - -ktime_t ktime_add_ns(const ktime_t kt, u64 nsec) { KTIME_RET; } -ktime_t ktime_get_monotonic_offset(void) { KTIME_RET; } -ktime_t ktime_sub(const ktime_t lhs, const ktime_t rhs) { KTIME_RET; } -ktime_t ktime_get_real(void) { TRACE; ktime_t ret; return ret; } -ktime_t ktime_get_boottime(void) { TRACE; KTIME_RET; } - -s64 ktime_us_delta(const ktime_t later, const ktime_t earlier) { TRACE; return 0; }; - - -/******************* - ** linux/timer.h ** - *******************/ - -unsigned long round_jiffies(unsigned long j) { TRACE; return 1; } -void set_timer_slack(struct timer_list *time, int slack_hz) { TRACE; } - - -/******************* - ** linux/delay.h ** - *******************/ - -void usleep_range(unsigned long min, unsigned long max) { TRACE; } - - -/*********************** - ** linux/workquque.h ** - ***********************/ - -void destroy_workqueue(struct workqueue_struct *wq) { TRACE; } - -bool flush_work(struct work_struct *work) { TRACE; return 0; } -bool flush_work_sync(struct work_struct *work) { TRACE; return 0; } - - -/****************** - ** linux/time.h ** - ******************/ - -struct timespec current_kernel_time(void) -{ - struct timespec t = { 0, 0 }; - return t; -} - -void do_gettimeofday(struct timeval *tv) { TRACE; } - - -/******************* - ** linux/sched.h ** - *******************/ - -int kill_pid_info_as_cred(int i, struct siginfo *s, struct pid *p, - const struct cred *c, u32 v) { TRACE; return 0; } -pid_t task_pid_nr(struct task_struct *tsk) { TRACE; return 0; } -struct pid *task_pid(struct task_struct *task) { TRACE; return NULL; } -void __set_current_state(int state) { TRACE; } -int signal_pending(struct task_struct *p) { TRACE; return 0; } -void schedule(void) { TRACE; } -void yield(void) { TRACE; } -void cpu_relax(void) { SKIP; } - -struct task_struct *current; - - -/********************* - ** linux/kthread.h ** - *********************/ - -int kthread_should_stop(void) { SKIP; return 0; } -int kthread_stop(struct task_struct *k) { TRACE; return 0; } - - -/********************** - ** linux/notifier.h ** - **********************/ - -int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, - struct notifier_block *nb) { TRACE; return 0; } -int atomic_notifier_chain_register(struct atomic_notifier_head *nh, - struct notifier_block *nb) { TRACE; return 0; } -int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, - struct notifier_block *nb) { TRACE; return 0; } - - - -/********************* - ** linux/kobject.h ** - *********************/ - -int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) { TRACE; return 0; } -const char *kobject_name(const struct kobject *kobj) { TRACE; return 0; } -char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask) { TRACE; return 0; } - - -/******************* - ** linux/sysfs.h ** - *******************/ - -int sysfs_create_group(struct kobject *kobj, - const struct attribute_group *grp) { TRACE; return 0; } -void sysfs_remove_group(struct kobject *kobj, - const struct attribute_group *grp) { TRACE; } -int sysfs_create_link(struct kobject *kobj, struct kobject *target, - const char *name) { TRACE; return 0; } -void sysfs_remove_link(struct kobject *kobj, const char *name) { TRACE; } - -int sysfs_create_files(struct kobject *kobj, const struct attribute **attr) { TRACE; return 1; } - -int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp) { TRACE; return 0; } - -ssize_t simple_read_from_buffer(void __user *to, size_t count, - loff_t *ppos, const void *from, size_t available) { TRACE; return 0; } - -/************************ - ** linux/pm_runtime.h ** - ************************/ - -bool pm_runtime_active(struct device *dev) { SKIP; return true; } -int pm_runtime_set_active(struct device *dev) { SKIP; return 0; } -void pm_suspend_ignore_children(struct device *dev, bool enable) { SKIP; } -void pm_runtime_enable(struct device *dev) { SKIP; } -void pm_runtime_disable(struct device *dev) { SKIP; } -void pm_runtime_allow(struct device *dev) { SKIP; } -void pm_runtime_forbid(struct device *dev) { SKIP; } -void pm_runtime_set_suspended(struct device *dev) { SKIP; } -void pm_runtime_get_noresume(struct device *dev) { SKIP; } -void pm_runtime_put_noidle(struct device *dev) { SKIP; } -void pm_runtime_use_autosuspend(struct device *dev) { SKIP; } -int pm_runtime_put_sync_autosuspend(struct device *dev) { SKIP; return 0; } -void pm_runtime_no_callbacks(struct device *dev) { SKIP; } -void pm_runtime_set_autosuspend_delay(struct device *dev, int delay) { SKIP; } -int pm_runtime_get_sync(struct device *dev) { SKIP; return 0; } -int pm_runtime_put_sync(struct device *dev) { SKIP; return 0; } -int pm_runtime_put(struct device *dev) { SKIP; return 0; } -int pm_runtime_barrier(struct device *dev) { SKIP; return 0; } - - -/*********************** - ** linux/pm_wakeup.h ** - ***********************/ - -int device_init_wakeup(struct device *dev, bool val) { TRACE; return 0; } -int device_wakeup_enable(struct device *dev) { TRACE; return 0; } -bool device_may_wakeup(struct device *dev) { TRACE; return 1; } -int device_set_wakeup_enable(struct device *dev, bool enable) { TRACE; return 0; } -bool device_can_wakeup(struct device *dev) { TRACE; return 0; } - - -/******************** - ** linux/pm_qos.h ** - ********************/ - -int dev_pm_qos_expose_flags(struct device *dev, s32 value) { TRACE; return 0; } -int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, - enum dev_pm_qos_req_type type, s32 value) { TRACE; return 0; } -int dev_pm_qos_remove_request(struct dev_pm_qos_request *req) { TRACE; return 0; } - - -/******************** - ** linux/device.h ** - ********************/ - -int dev_set_name(struct device *dev, const char *name, ...) { TRACE; return 0; } -int dev_to_node(struct device *dev) { TRACE; return 0; } -void set_dev_node(struct device *dev, int node) { TRACE; } - -struct device *device_create(struct class *cls, struct device *parent, - dev_t devt, void *drvdata, - const char *fmt, ...) { TRACE; return NULL; } -void device_destroy(struct class *cls, dev_t devt) { TRACE; } -void device_lock(struct device *dev) { TRACE; } -int device_trylock(struct device *dev) { TRACE; return 0; } -void device_unlock(struct device *dev) { TRACE; } -void device_initialize(struct device *dev) { TRACE; } -int device_attach(struct device *dev) { TRACE; return 0; } -int device_bind_driver(struct device *dev) { TRACE; return 0; } -void device_enable_async_suspend(struct device *dev) { TRACE; } -void device_set_wakeup_capable(struct device *dev, bool capable) { TRACE; } -int device_create_bin_file(struct device *dev, - const struct bin_attribute *attr) { TRACE; return 0; } -void device_remove_bin_file(struct device *dev, - const struct bin_attribute *attr) { TRACE; } -int device_create_file(struct device *device, - const struct device_attribute *entry) { TRACE; return 0; } -void device_remove_file(struct device *dev, - const struct device_attribute *attr) { TRACE; } -int device_for_each_child(struct device *dev, void *data, - int (*fn)(struct device *dev, void *data)) { TRACE; return 0; } - -void driver_unregister(struct device_driver *drv) { TRACE; } -int driver_attach(struct device_driver *drv) { TRACE; return 0; } -int driver_create_file(struct device_driver *driver, - const struct driver_attribute *attr) { TRACE; return 0; } -void driver_remove_file(struct device_driver *driver, - const struct driver_attribute *attr) { TRACE; } - -struct device_driver *get_driver(struct device_driver *drv) { TRACE; return NULL; } -void put_driver(struct device_driver *drv) { TRACE; } - -struct device *bus_find_device(struct bus_type *bus, struct device *start, - void *data, - int (*match)(struct device *dev, void *data)) { TRACE; return NULL; } -int bus_register(struct bus_type *bus) { TRACE; return 0; } -void bus_unregister(struct bus_type *bus) { TRACE; } -int bus_register_notifier(struct bus_type *bus, - struct notifier_block *nb) { TRACE; return 0; } -int bus_unregister_notifier(struct bus_type *bus, - struct notifier_block *nb) { TRACE; return 0; } -int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, - int (*fn)(struct device *dev, void *data)) { TRACE; return 0; } - -struct class *__class_create(struct module *owner, - const char *name, - struct lock_class_key *key) { TRACE; return NULL; } -int class_register(struct class *cls) { TRACE; return 0; } -void class_unregister(struct class *cls) { TRACE; } -void class_destroy(struct class *cls) { TRACE; } - -void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp) { TRACE; return 0; } -void devres_add(struct device *dev, void *res) { TRACE; } -int devres_destroy(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data) { TRACE; return 0; } -void devres_free(void *res) { TRACE; } - -void devm_kfree(struct device *dev, void *p) { TRACE; } - - -/***************************** - ** linux/platform_device.h ** - *****************************/ - -int platform_device_del(struct platform_device *pdev) { TRACE; return 0; } -int platform_device_put(struct platform_device *pdev) { TRACE; return 0; } -void platform_device_unregister(struct platform_device *pdev) { TRACE; } - - -/******************** - ** linux/dcache.h ** - ********************/ - -void d_instantiate(struct dentry *dentry, struct inode *i) { TRACE; } -int d_unhashed(struct dentry *dentry) { TRACE; return 0; } -void d_delete(struct dentry *d) { TRACE; } -struct dentry *d_alloc_root(struct inode *i) { TRACE; return NULL; } -struct dentry *dget(struct dentry *dentry) { TRACE; return NULL; } -void dput(struct dentry *dentry) { TRACE; } - -void dont_mount(struct dentry *dentry) { TRACE; } - - -/****************** - ** linux/poll.h ** - ******************/ - -void poll_wait(struct file *f, wait_queue_head_t *w, poll_table *p) { TRACE; } - - -/******************** - ** linux/statfs.h ** - ********************/ - -loff_t default_llseek(struct file *file, loff_t offset, int origin) { TRACE; return 0; } - - -/**************** - ** linux/fs.h ** - ****************/ - -unsigned iminor(const struct inode *inode) { TRACE; return 0; } -unsigned imajor(const struct inode *inode) { TRACE; return 0; } - -int register_chrdev_region(dev_t d, unsigned v, const char *s) { TRACE; return 0; } -void unregister_chrdev_region(dev_t d, unsigned v) { TRACE; } -void fops_put(struct file_operations const *fops) { TRACE; } -loff_t noop_llseek(struct file *file, loff_t offset, int origin) { TRACE; return 0; } -int register_chrdev(unsigned int major, const char *name, - const struct file_operations *fops) { TRACE; return 0; } -void unregister_chrdev(unsigned int major, const char *name) { TRACE; } -struct inode *new_inode(struct super_block *sb) { TRACE; return NULL; } -unsigned int get_next_ino(void) { TRACE; return 0; } -void init_special_inode(struct inode *i, umode_t m, dev_t d) { TRACE; } -int generic_delete_inode(struct inode *inode) { TRACE; return 0; } -void drop_nlink(struct inode *inode) { TRACE; } -void inc_nlink(struct inode *inode) { TRACE; } -void dentry_unhash(struct dentry *dentry) { TRACE; } -void iput(struct inode *i) { TRACE; } -struct dentry *mount_single(struct file_system_type *fs_type, - int flags, void *data, - int (*fill_super)(struct super_block *, - void *, int)) { TRACE; return NULL; } -int nonseekable_open(struct inode *inode, struct file *filp) { TRACE; return 0; } -int simple_statfs(struct dentry *d, struct kstatfs *k) { TRACE; return 0; } -int simple_pin_fs(struct file_system_type *t, struct vfsmount **mount, int *count) { TRACE; return 0; } -void simple_release_fs(struct vfsmount **mount, int *count) { TRACE; } -void kill_litter_super(struct super_block *sb) { TRACE; } -int register_filesystem(struct file_system_type *t) { TRACE; return 0; } -int unregister_filesystem(struct file_system_type *t) { TRACE; return 0; } - -void kill_fasync(struct fasync_struct **fp, int sig, int band) { TRACE; } -int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp) { TRACE; return 0; } -const struct file_operations simple_dir_operations; -const struct inode_operations simple_dir_inode_operations; - - -struct inode *file_inode(struct file *f) -{ - TRACE; - static struct inode _i; - return &_i; -} - -/******************* - ** linux/namei.h ** - *******************/ - -struct dentry *lookup_one_len(const char *c, struct dentry *e, int v) { TRACE; return NULL; } - - -/********************** - ** linux/seq_file.h ** - **********************/ - -int seq_printf(struct seq_file *f, const char *fmt, ...) { TRACE; return 0; } -int seq_putc(struct seq_file *f, char c) { TRACE; return 0;} - - -/***************** - ** linux/gfp.h ** - *****************/ - -unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) { TRACE; return 0; } -void __free_pages(struct page *p, unsigned int order) { TRACE; } -void free_pages(unsigned long addr, unsigned int order) { TRACE; } - - -/********************* - ** linux/proc_fs.h ** - *********************/ - -struct proc_dir_entry *proc_mkdir(const char *s,struct proc_dir_entry *e) { TRACE; return NULL; } -void remove_proc_entry(const char *name, struct proc_dir_entry *parent) { TRACE; } - - -/******************** - * linux/debugfs.h ** - ********************/ - -struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) { TRACE; return (struct dentry *)1; } -struct dentry *debugfs_create_file(const char *name, mode_t mode, - struct dentry *parent, void *data, - const struct file_operations *fops) { TRACE; return (struct dentry *)1; } -void debugfs_remove(struct dentry *dentry) { TRACE; } - - -/************************ - ** linux/page-flags.h ** - ************************/ - -bool is_highmem(void *ptr) { TRACE; return 0; } - - -/**************** - ** linux/mm.h ** - ****************/ - -struct zone *page_zone(const struct page *page) { TRACE; return NULL; } -int is_vmalloc_addr(const void *x) { TRACE; return 0; } -void kvfree(const void *addr) { TRACE; } - - -/********************** - ** linux/highmem.h ** - **********************/ - -void *kmap(struct page *page) { TRACE; return 0; } -void kunmap(struct page *page) { TRACE; } - - -/********************** - ** asm-generic/io.h ** - **********************/ - -void iounmap(volatile void *addr) { TRACE; } -void native_io_delay(void) { TRACE; } - - -/******************** - ** linux/ioport.h ** - ********************/ - -void release_region(resource_size_t start, resource_size_t n) { TRACE; } -void release_mem_region(resource_size_t start, resource_size_t n) { TRACE; } - -/** - * SKIP - */ - -/* implemented in Pci_driver */ -struct resource *request_region(resource_size_t start, resource_size_t n, - const char *name) { SKIP; return (struct resource *)1; } -/* implemented in Pci_driver */ -struct resource *request_mem_region(resource_size_t start, resource_size_t n, - const char *name) { SKIP; return (struct resource *)1; } - -/*********************** - ** linux/interrupt.h ** - ***********************/ - -void local_irq_enable(void) { TRACE; } -void local_irq_disable(void) { TRACE; } -void free_irq(unsigned int i, void *p) { TRACE; } - - -/********************* - ** linux/hardirq.h ** - *********************/ - -void synchronize_irq(unsigned int irq) { TRACE; } -bool in_interrupt(void) { TRACE; return 1; } - - -/***************** - ** linux/pci.h ** - *****************/ - - -void *pci_get_drvdata(struct pci_dev *pdev) { TRACE; return NULL; } -struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, - struct pci_dev *from) { TRACE; return NULL; } - - -void pci_disable_device(struct pci_dev *dev) { TRACE; } -int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) { TRACE; return 0; } - -void pci_unregister_driver(struct pci_driver *drv) { TRACE; } - -bool pci_dev_run_wake(struct pci_dev *dev) { TRACE; return 0; } -int pci_set_mwi(struct pci_dev *dev) { TRACE; return 0; } -int pci_find_capability(struct pci_dev *dev, int cap) { TRACE; return 0; } -struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn) { TRACE; return NULL; } -const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, - struct pci_dev *dev) { TRACE; return 0; } -void *pci_ioremap_bar(struct pci_dev *pdev, int bar); - -int pci_enable_msi(struct pci_dev *pdev) { TRACE; return -1; } -void pci_disable_msi(struct pci_dev *pdev) { TRACE; } - -int pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int vec) { TRACE; return -1; } -int pci_enable_msix_exact(struct pci_dev *pdef,struct msix_entry *entries, int vec) { TRACE; return -1; } -void pci_disable_msix(struct pci_dev *pdev) { TRACE; } - - -int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { TRACE; return 0; } - - -/** - * Omitted PCI functions - */ -/* scans resources, this is already implemented in 'pci_driver.cc' */ -int pci_enable_device(struct pci_dev *dev) { SKIP; return 0; } - -/* implemented in Pci_driver::_setup_pci_device */ -void pci_set_master(struct pci_dev *dev) { SKIP; } - -/********************** - ** linux/irqflags.h ** - **********************/ - -unsigned long local_irq_save(unsigned long flags) { SKIP; return 0; } -unsigned long local_irq_restore(unsigned long flags) { SKIP; return 0; } -unsigned smp_processor_id() { return 0; } - -/************************* - ** linux/scatterlist.h ** - *************************/ - -void sg_init_table(struct scatterlist *sg, unsigned int nents) { TRACE; } -void sg_set_buf(struct scatterlist *sg, const void *buf, unsigned int buflen) { TRACE; } -void sg_set_page(struct scatterlist *sg, struct page *page, - unsigned int len, unsigned int offset) { TRACE; } -int sg_nents(struct scatterlist *sg) { TRACE; return 0; } - -void sg_miter_start(struct sg_mapping_iter *miter, struct scatterlist *sgl, - unsigned int nents, unsigned int flags) { TRACE; } -bool sg_miter_skip(struct sg_mapping_iter *miter, off_t offset) { TRACE; return false;} -bool sg_miter_next(struct sg_mapping_iter *miter) { TRACE; return false; } -void sg_miter_stop(struct sg_mapping_iter *miter) { TRACE; } - - -/************************* - ** linux/dma-mapping.h ** - *************************/ - -void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, - size_t size, - enum dma_data_direction dir, - struct dma_attrs *attrs) { SKIP; } - -void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction dir, - struct dma_attrs *attrs) { SKIP; } - - -void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, - enum dma_data_direction direction) { SKIP; } - -int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { SKIP; return 0; } - - -/********************* - ** linux/uaccess.h ** - *********************/ - -unsigned long clear_user(void *to, unsigned long n) { TRACE; return 0; } - -/***************** - ** linux/pid.h ** - *****************/ - -void put_pid(struct pid *pid) { TRACE; } -struct pid *get_pid(struct pid *pid) { TRACE; return NULL; } - - -/****************** - ** linux/cred.h ** - ******************/ - -void put_cred(struct cred const *c) { TRACE; } -const struct cred *get_cred(const struct cred *cred) { TRACE; return NULL; } - - -/********************** - ** linux/security.h ** - **********************/ - -void security_task_getsecid(struct task_struct *p, u32 *secid) { TRACE; } - - -/****************** - ** linux/cdev.h ** - ******************/ - -void cdev_init(struct cdev *c, const struct file_operations *fops) { TRACE; } -int cdev_add(struct cdev *c, dev_t d, unsigned v) { TRACE; return 0; } -void cdev_del(struct cdev *c) { TRACE; } - - -/********************* - ** linux/utsname.h ** - *********************/ - -struct new_utsname *init_utsname(void) -{ - static struct new_utsname uts = { .sysname = "Genode.UTS", .release = "1.0" }; - return &uts; -} -struct new_utsname *utsname(void) { TRACE; return NULL; } - - -/********************* - ** linux/freezer.h ** - *********************/ - -void set_freezable(void) { TRACE; } - - -/******************** - ** linux/parser.h ** - ********************/ - -int match_token(char *s, const match_table_t table, substring_t args[]) { TRACE; return 0; } -int match_int(substring_t *s, int *result) { TRACE; return 0; } -int match_octal(substring_t *s, int *result) { TRACE; return 0; } - - -/********************* - ** linux/semaphore ** - *********************/ - -void sema_init(struct semaphore *sem, int val) { SKIP; } -int down_trylock(struct semaphore *sem) { SKIP; return 0; } -int down_interruptible(struct semaphore *sem) { SKIP; return 0; } -void up(struct semaphore *sem) { SKIP; } - - -/******************* - ** linux/input.h ** - *******************/ - -void input_ff_destroy(struct input_dev *dev) { TRACE; } -int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { TRACE; return 0; } -int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file) { TRACE; return 0; } -int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file) { TRACE; return 0; } - -/********************* - ** input-compat.h" ** - *********************/ - -int input_event_from_user(const char __user *buffer, struct input_event *event) { TRACE; return 0; } -int input_event_to_user(char __user *buffer, const struct input_event *event) { TRACE; return 0; } -int input_ff_effect_from_user(const char __user *buffer, size_t size, struct ff_effect *effect) { TRACE; return 0;} - - -/********************* - ** linux/vmalloc.h ** - *********************/ - -void *vmalloc(unsigned long size) { TRACE; return 0; } - - -/******************** - ** linux/blkdev.h ** - ********************/ - -void blk_queue_bounce_limit(struct request_queue *q, u64 dma_mask) { TRACE; } -void blk_queue_update_dma_alignment(struct request_queue *q, int mask) { TRACE; } -void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors) { TRACE; } -unsigned int queue_max_hw_sectors(struct request_queue *q) { TRACE; return 0; } - - -/********************** - ** scsi/scsi_cmnd.h ** - **********************/ - -void scsi_set_resid(struct scsi_cmnd *cmd, int resid) { SKIP; } -int scsi_get_resid(struct scsi_cmnd *cmd) { SKIP; return 0; } - - -/******************** - ** scsi/scsi_eh.h ** - *******************/ - -void scsi_report_bus_reset(struct Scsi_Host *shost, int channel) { TRACE; } -void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target) { TRACE; } - - - -int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, - struct scsi_sense_hdr *sshdr) { TRACE; return 0; } - -const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len, - int desc_type) { TRACE; return 0; } - - -/*********************** - ** drivers/scsi/sd.h ** - **********************/ - -struct scsi_disk *scsi_disk(struct gendisk *disk) { TRACE; return 0; } - - -/********************** - ** scsi/scsi_host.h ** - **********************/ -int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, - struct device *dma_dev) { TRACE; return 0; } -void scsi_remove_host(struct Scsi_Host *shost) { TRACE; } -void scsi_host_put(struct Scsi_Host *shost) { TRACE; } -struct scsi_device *scsi_get_host_dev(struct Scsi_Host *shost) { TRACE; return 0; } -int scsi_is_host_device(const struct device *dev) { TRACE; return 0; } - - -/******************************** - ** linux/regulator/consumer.h ** - ********************************/ -struct regulator; -int regulator_enable(struct regulator *r) { TRACE; return 0; } -int regulator_disable(struct regulator *r) { TRACE; return 0; } -void regulator_put(struct regulator *r) { TRACE; } -struct regulator *regulator_get(struct device *dev, const char *id) { TRACE; return 0; } - - -/******************************************* - ** arch/arm/plat-omap/include/plat/usb.h ** - *******************************************/ - -int omap_usbhs_enable(struct device *dev) { TRACE; return 0; } -void omap_usbhs_disable(struct device *dev) { TRACE; } - - -/***************** - ** linux/net.h ** - *****************/ - -int net_ratelimit(void) { TRACE; return 0; } - -/******************** - ** linux/skbuff.h ** - ********************/ - -unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) { TRACE; return 0; } -int skb_checksum_start_offset(const struct sk_buff *skb) { TRACE; return 0; } -struct sk_buff *skb_copy_expand(const struct sk_buff *skb, - int newheadroom, int newtailroom, - gfp_t gfp_mask) { TRACE; return 0; } - -int skb_queue_empty(const struct sk_buff_head *list) { TRACE; return 1; } -void skb_queue_purge(struct sk_buff_head *list) { TRACE; } - -void skb_tx_timestamp(struct sk_buff *skb) { TRACE; } -bool skb_defer_rx_timestamp(struct sk_buff *skb) { TRACE; return 0; } - -int skb_linearize(struct sk_buff *skb) { TRACE; return 0; } - -unsigned int skb_headlen(const struct sk_buff *skb) { TRACE; return 0; } -unsigned int skb_frag_size(const skb_frag_t *frag) { TRACE; return 0; } - -int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, gfp_t mask) { TRACE; return 0; } - -/********************* - ** linux/ethtool.h ** - *********************/ - -__u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) { TRACE; return 0; } -u32 ethtool_op_get_link(struct net_device *dev) { TRACE; return 0; } -int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti) { - TRACE; return 0; } - - -/*********************** - ** linux/netdevice.h ** - ***********************/ - -u32 netif_msg_init(int debug_value, int default_msg_enable_bits) { TRACE; return 0; } - -void netif_start_queue(struct net_device *dev) { TRACE; } -void netif_device_detach(struct net_device *dev) { TRACE; } -void netif_stop_queue(struct net_device *dev) { TRACE; } -void netif_wake_queue(struct net_device *dev) { TRACE; } -void netif_tx_wake_all_queues(struct net_device *dev) { TRACE; } -void netif_device_attach(struct net_device *dev) { TRACE; } -void unregister_netdev(struct net_device *dev) { TRACE; } -void free_netdev(struct net_device *dev) { TRACE; } - -int netdev_mc_empty(struct net_device *dev) { TRACE; return 1; } -unsigned netdev_mc_count(struct net_device * dev) { TRACE; return 1; } - - -/***************** - ** linux/mii.h ** - *****************/ - -int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) { TRACE; return 0; } - -int generic_mii_ioctl(struct mii_if_info *mii_if, - struct mii_ioctl_data *mii_data, int cmd, - unsigned int *duplex_changed) { TRACE; return 0; } -struct mii_ioctl_data *if_mii(struct ifreq *rq) { TRACE; return 0; } - - -/*********************** - ** uapi/linux/mdio.h ** - ***********************/ - -u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv) { TRACE; return 0; } -u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv) { TRACE; return 0; } -u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap) { TRACE; return 0; } - - -/************************* - ** linux/etherdevice.h ** - *************************/ - -__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) { TRACE; return 0; } -int eth_mac_addr(struct net_device *dev, void *p) { TRACE; return 0; } -int eth_validate_addr(struct net_device *dev) { TRACE; return 0; } -bool ether_addr_equal(const u8 *addr1, const u8 *addr2) { TRACE; return 0; } - - -/********************** - ** linux/inerrupt.h ** - **********************/ - -void tasklet_kill(struct tasklet_struct *t) { TRACE; } - - -/******************** - ** asm/checksum.h ** - ********************/ - -__wsum csum_partial(const void *buff, int len, __wsum wsum) { TRACE; return 0; } -__sum16 csum_fold(__wsum sum) { TRACE; return 0; } - - -/***************** - ** linux/clk.h ** - *****************/ - -struct clk { }; - -struct clk *clk_get(struct device *dev, const char *id) -{ - static struct clk _c; - TRACE; - return &_c; -} - -int clk_enable(struct clk *clk) { TRACE; return 0; } -void clk_disable(struct clk *clk) { TRACE; } -void clk_put(struct clk *clk) { TRACE; } - -struct clk *devm_clk_get(struct device *dev, const char *id) { TRACE; return 0; } -int clk_prepare_enable(struct clk *clk) { TRACE; return 0; } -void clk_disable_unprepare(struct clk *clk) { TRACE; } - - -/******************** - ** linux/bitmap.h ** - ********************/ - -int bitmap_subset(const unsigned long *src1, - const unsigned long *src2, int nbits) { TRACE; return 1; } - -int bitmap_weight(const unsigned long *src, unsigned int nbits) { TRACE; return 0; } - - -/***************** - ** linux/idr.h ** - *****************/ - -int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, - gfp_t gfp_mask) { TRACE; return 0; } -void ida_simple_remove(struct ida *ida, unsigned int id) { TRACE; } - - -/**************************** - ** drivers/usb/core/usb.h ** - ****************************/ - -#include -#include - -const struct attribute_group *usb_interface_groups[1]; -const struct attribute_group *usb_device_groups[1]; -struct usb_driver usbfs_driver; - -DEFINE_MUTEX(usbfs_mutex); - -void usb_create_sysfs_intf_files(struct usb_interface *intf) { TRACE; } -void usb_remove_sysfs_intf_files(struct usb_interface *intf) { TRACE; } - -int usb_create_sysfs_dev_files(struct usb_device *dev) { TRACE; return 0; } -void usb_remove_sysfs_dev_files(struct usb_device *dev) { TRACE; } - -int usb_devio_init(void) { TRACE; return 0; } -void usb_devio_cleanup(void) { TRACE; } - - -/******************* - ** linux/crc16.h ** - *******************/ - -u16 crc16(u16 crc, const u8 *buffer, size_t len) { TRACE; return 0; } - - -/******************* - ** linux/birev.h ** - *******************/ - -u16 bitrev16(u16 in) { TRACE; return 0; } - - -/************************ - ** linux/radix-tree.h ** - ************************/ - -void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index) { TRACE; return 0; } -void *radix_tree_delete(struct radix_tree_root *root, unsigned long index) { TRACE; return 0; } -void radix_tree_preload_end(void) { TRACE; } - -int radix_tree_insert(struct radix_tree_root *root, unsigned long index, void *item) { TRACE; return 0; } -int radix_tree_maybe_preload(gfp_t gfp_mask) { TRACE; return 0; } - -/****************** - ** linux/gpio.h ** - ******************/ - -bool gpio_is_valid(int number) { TRACE; return false; } -void gpio_set_value_cansleep(unsigned gpio, int value) { TRACE; } -int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) { TRACE; return 0; } - -int devm_gpio_request_one(struct device *dev, unsigned gpio, - unsigned long flags, const char *label) { TRACE; return 0; } - - -/********************* - ** linux/of_gpio.h ** - *********************/ - - int of_get_named_gpio(struct device_node *np, - const char *propname, int index) { TRACE; return 0; } - - -/******************** - ** linux/module.h ** - ********************/ - -void module_put(struct module *m) { TRACE; } -void __module_get(struct module *m) { TRACE; } - - -/****************** - ** linux/phy.h ** - ******************/ - -#include - -struct mii_bus *mdiobus_alloc(void) { TRACE; return 0; } -int mdiobus_register(struct mii_bus *bus) { TRACE; return 0; } -void mdiobus_unregister(struct mii_bus *bus) { TRACE; } -void mdiobus_free(struct mii_bus *bus) { TRACE; } - -int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd) { TRACE; return 0; } -void phy_print_status(struct phy_device *phydev) { TRACE; } -int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) { TRACE; return 0; } -int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd) { TRACE; return 0; } -int phy_start_aneg(struct phy_device *phydev) { TRACE; return 0; } -void phy_start(struct phy_device *phydev) { TRACE; } -void phy_stop(struct phy_device *phydev) { TRACE; } -int phy_init(struct phy *phy) { TRACE; return 0; } -int phy_exit(struct phy *phy) { TRACE; return 0; } -int phy_power_on(struct phy *phy) { TRACE; return 0; } -int phy_power_off(struct phy *phy) { TRACE; return 0; } -int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id) { TRACE; return 0; } -void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id) { TRACE; } - -int genphy_resume(struct phy_device *phydev) { TRACE; return 0; } - -struct phy_device * phy_connect(struct net_device *dev, const char *bus_id, - void (*handler)(struct net_device *), - phy_interface_t interface) { TRACE; return 0; } -void phy_disconnect(struct phy_device *phydev) { TRACE; } - -struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, const char *phandle, u8 index) { TRACE; return 0; } -struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type) { TRACE; return 0; } -struct usb_phy *devm_usb_get_phy_dev(struct device *dev, u8 index) { TRACE; return 0; } - -struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index) { TRACE; return 0; } -void usb_put_phy(struct usb_phy *x) { TRACE; } - -struct phy *devm_phy_get(struct device *dev, const char *string) { TRACE; return 0; } - - -/**************** - ** linux/of.h ** - ****************/ - -struct of_dev_auxdata; -bool of_property_read_bool(const struct device_node *np, const char *propname) { TRACE; return false; } -unsigned of_usb_get_maximum_speed(struct device_node *np) { TRACE; return 0; } -unsigned of_usb_get_dr_mode(struct device_node *np) { TRACE; return 0; } -int of_platform_populate(struct device_node *root, const struct of_device_id *matches, - const struct of_dev_auxdata *lookup, struct device *parent) { TRACE; return 0; } -int of_device_is_compatible(const struct device_node *device, const char *compat) { TRACE; return 1; } - - -/********************** - ** linux/property.h ** - **********************/ - -bool device_property_read_bool(struct device *dev, const char *propname) { TRACE; return false; } -int device_property_read_u8(struct device *dev, const char *propname, u8 *val) { TRACE; return 0; } - -int device_property_read_string(struct device *dev, const char *propname, - const char **val) { TRACE; *val = 0; return -EINVAL; } -int device_property_read_u32(struct device *dev, const char *propname, u32 *val) { TRACE; return 0; } - - -/****************************** - ** drivers/usb/dwc3/debug.h ** - ******************************/ - -struct dwc3; - -int dwc3_debugfs_init(struct dwc3 *d){ SKIP; return 0; } -void dwc3_debugfs_exit(struct dwc3 *d) { SKIP; } -void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...) { SKIP; } - - -/************************** - ** linux/power_supply.h ** - **************************/ - -#include -struct power_supply * -power_supply_register(struct device *parent, const struct power_supply_desc *desc, - const struct power_supply_config *cfg) { TRACE; return 0; } -void power_supply_unregister(struct power_supply *psy) { TRACE; } -int power_supply_powers(struct power_supply *psy, struct device *dev) { TRACE; return 0; } -void *power_supply_get_drvdata(struct power_supply *psy) { TRACE; return 0; } -void power_supply_changed(struct power_supply *psy) { TRACE; } - - -/********************* - ** linux/kobject.h ** - *********************/ - -void kobject_put(struct kobject *kobj) { TRACE; } -struct kobject *kobject_create_and_add(const char *name, struct kobject *kobj) { TRACE; return 0; } diff --git a/repos/dde_linux/src/drivers/usb/include/lx_emul.h b/repos/dde_linux/src/drivers/usb/include/lx_emul.h deleted file mode 100644 index ad71d59039..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/lx_emul.h +++ /dev/null @@ -1,3271 +0,0 @@ -/* - * \brief Emulation of the Linux kernel API - * \author Norman Feske - * \author Sebastian Sumpf - * \date 2012-01-28 - * - * The content of this file, in particular data structures, is partially - * derived from Linux-internal headers. - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _LX_EMUL_H_ -#define _LX_EMUL_H_ - -#include -#include - -#include - -#define DEBUG_COMPLETION 0 -#define DEBUG_DMA 0 -#define DEBUG_DRIVER 0 -#define DEBUG_KREF 0 -#define DEBUG_LINUX_PRINTK 0 -#define DEBUG_PCI 0 -#define DEBUG_SKB 0 -#define DEBUG_SLAB 0 -#define DEBUG_TIMER 0 -#define DEBUG_THREAD 0 -#define DEBUG_TRACE 0 - -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#define LINUX_VERSION_CODE KERNEL_VERSION(4,4,3) - -#define KBUILD_MODNAME "mod-noname" - -/* lx_printf */ -#include - -static inline void bt() -{ - lx_printf("BT: 0x%p\n", __builtin_return_address(0)); -} - - -/******************* - ** linux/sizes.h ** - *******************/ - -#define SZ_256K 0x40000 /* needed by 'dwc_otg_attr.c' */ - - -/***************** - ** linux/bcd.h ** - *****************/ - -#define bin2bcd(x) ((((x) / 10) << 4) + (x) % 10) - - -/*************** - ** asm/bug.h ** - ***************/ - -#include - -/***************** - ** asm/param.h ** - *****************/ - -enum { HZ = 100UL }; - - -/******************* - ** linux/magic.h ** - *******************/ - -enum { USBDEVICE_SUPER_MAGIC = 0x9fa2 }; - - -/****************** - ** asm/atomic.h ** - ******************/ - -typedef struct atomic { unsigned int v; } atomic_t; -typedef void* atomic_long_t; - -void atomic_set(atomic_t *p, unsigned int v); -unsigned int atomic_read(atomic_t *p); - -void atomic_inc(atomic_t *v); -void atomic_dec(atomic_t *v); - -void atomic_add(int i, atomic_t *v); -void atomic_sub(int i, atomic_t *v); -int atomic_inc_return(atomic_t *v); - -#define ATOMIC_INIT(i) { (i) } - - -/******************* - ** linux/types.h ** - *******************/ - -#include - -typedef __u16 __le16; -typedef __u32 __le32; -typedef __u64 __le64; -typedef __u64 __be64; - -typedef __u16 __sum16; -typedef __u32 __wsum; - -typedef u64 sector_t; -typedef int clockid_t; - - -#ifndef __cplusplus -typedef u16 wchar_t; -#endif - -/* - * Needed by 'dwc_common_port/usb.h' - */ -typedef unsigned int u_int; -typedef unsigned char u_char; -typedef unsigned long u_long; -typedef uint8_t u_int8_t; -typedef uint16_t u_int16_t; -typedef uint32_t u_int32_t; - -/* - * Needed by 'dwc_otg/dwc_otg/dwc_otg_fiq_fsm.h' - */ -typedef unsigned short ushort; - -typedef unsigned long phys_addr_t; - -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, 8 * sizeof(long)) -#define DECLARE_BITMAP(name,bits) \ - unsigned long name[BITS_TO_LONGS(bits)] - - -#include - - -/********************** - ** linux/compiler.h ** - **********************/ - -#include - -#define notrace /* needed by 'dwc_otg_hcd_intr.c' */ -#define __must_hold(x) - - -/********************* - ** uapi/linux/uuid ** - *********************/ - -typedef struct { __u8 b[16]; } uuid_le; - - -/******************************* - ** linux/byteorder/generic.h ** - *******************************/ - -#include - -struct __una_u16 { u16 x; } __attribute__((packed)); -struct __una_u32 { u32 x; } __attribute__((packed)); -struct __una_u64 { u64 x; } __attribute__((packed)); - -u16 get_unaligned_le16(const void *p); -void put_unaligned_le16(u16 val, void *p); - -void put_unaligned_le32(u32 val, void *p); -u32 get_unaligned_le32(const void *p); - -void put_unaligned_be32(u32 val, void *p); - -void put_unaligned_le64(u64 val, void *p); -u64 get_unaligned_le64(const void *p); - -#define put_unaligned put_unaligned_le32 -#ifdef __LP64__ -#define get_unaligned get_unaligned_le64 -#else -#define get_unaligned get_unaligned_le32 -#endif - -/********************************* - ** linux/unaligned/access_ok.h ** - *********************************/ - -static inline u16 get_unaligned_be16(const void *p) -{ - return be16_to_cpup((__be16 *)p); -} - - -/**************** - ** asm/page.h ** - ****************/ - -/* - * For now, hardcoded to x86_32 - */ -enum { - PAGE_SIZE = 4096, - PAGE_SHIFT = 12, -}; - -struct page -{ - void *virt; - dma_addr_t phys; -}; - - -/******************************* - ** linux/errno.h and friends ** - *******************************/ - -#include - -enum { - EISDIR = 21, - EXFULL = 52, - ERESTART = 53, - ESHUTDOWN = 58, - ECOMM = 70, - EIDRM = 82, - ENOSR = 211, -}; - - -/******************* - ** linux/major.h ** - *******************/ - -enum { - INPUT_MAJOR = 13 -}; - - -/******************** - ** linux/kernel.h ** - ********************/ - -#include - -#undef swap - -char *bin2hex(char *dst, const void *src, size_t count); -int hex2bin(u8 *dst, const char *src, size_t count); - -char *kasprintf(gfp_t gfp, const char *fmt, ...); -int kstrtouint(const char *s, unsigned int base, unsigned int *res); -int kstrtoul(const char *s, unsigned int base, unsigned long *res); -int kstrtou8(const char *s, unsigned int base, u8 *res); - -#define rounddown(x, y) ( \ -{ \ - typeof(x) __x = (x); \ - __x - (__x % (y)); \ -}) - -#define PTR_ALIGN(p, a) ({ \ - unsigned long _p = (unsigned long)p; \ - _p = (_p + a - 1) & ~(a - 1); \ - p = (typeof(p))_p; \ - p; \ -}) - -int strict_strtoul(const char *s, unsigned int base, unsigned long *res); -long simple_strtoul(const char *cp, char **endp, unsigned int base); -long simple_strtol(const char *,char **,unsigned int); - -int hex_to_bin(char ch); - -unsigned long int_sqrt(unsigned long); - -/* - * Needed by 'usb.h' - */ -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); -int vsprintf(char *buf, const char *fmt, va_list args); -int snprintf(char *buf, size_t size, const char *fmt, ...); -int sprintf(char *buf, const char *fmt, ...); -int sscanf(const char *, const char *, ...); -int scnprintf(char *buf, size_t size, const char *fmt, ...); - - -/********************* - ** linux/preempt.h ** - *********************/ - -bool in_softirq(void); - -/********************* - ** linux/jiffies.h ** - *********************/ - -#include - - -/********************* - ** linux/cpumask.h ** - *********************/ - -static inline unsigned num_online_cpus(void) { return 1U; } - -/****************** - ** linux/log2.h ** - ******************/ - -int ilog2(u32 n); -int roundup_pow_of_two(u32 n); -int rounddown_pow_of_two(u32 n); - - -/******************** - ** linux/kdev_t.h ** - ********************/ - -#define MINORBITS 20 -#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi)) -#define MINOR(dev) ((dev) & 0xff) - - -/******************** - ** linux/printk.h ** - ********************/ - -enum { DUMP_PREFIX_NONE }; - -void print_hex_dump(const char *level, const char *prefix_str, - int prefix_type, int rowsize, int groupsize, - const void *buf, size_t len, bool ascii); - -#define pr_info(fmt, ...) printk(KERN_INFO fmt, ##__VA_ARGS__) -#define pr_err(fmt, ...) printk(KERN_ERR fmt, ##__VA_ARGS__) -#define pr_debug(fmt, ...) printk(KERN_DEBUG fmt, ##__VA_ARGS__) -#define pr_warning(fmt, ...) printk(KERN_WARNING fmt, ##__VA_ARGS__) -#define pr_warn_once pr_warning -#define pr_warn pr_warning - -bool printk_ratelimit(); -bool printk_ratelimited(); -bool printk_timed_ratelimit(unsigned long *, unsigned int); -#define printk_once(fmt, ...) - -/********************************** - ** linux/bitops.h, asm/bitops.h ** - **********************************/ - - -#define BIT(nr) (1UL << (nr)) -#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) - -/* normally declared in asm-generic/bitops/ffs.h */ -int ffs(int x); -int fls(int x); - -#include -#include -#include -#include - -static inline unsigned fls_long(unsigned long l) -{ - if (sizeof(l) == 4) - return fls(l); - return fls64(l); -} - -#define test_and_clear_bit(nr, addr) \ - __test_and_clear_bit(nr, (volatile unsigned long *)(addr)) -#define test_and_set_bit(nr, addr) \ - __test_and_set_bit(nr, (volatile unsigned long *)(addr)) -#define set_bit(nr, addr) \ - __set_bit(nr, (volatile unsigned long *)(addr)) -#define clear_bit(nr, addr) \ - __clear_bit(nr, (volatile unsigned long *)(addr)) - -/** - * Find first zero bit (limit to machine word size) - */ -long find_next_zero_bit_le(const void *addr, unsigned long size, unsigned long offset); -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset); - -#define find_next_zero_bit find_next_zero_bit_le -#define find_first_bit(addr, size) find_next_bit((addr), (size), 0) - -#define for_each_set_bit(bit, addr, size) \ - for ((bit) = find_first_bit((addr), (size)); \ - (bit) < (size); \ - (bit) = find_next_bit((addr), (size), (bit) + 1)) - - -/***************************************** - ** asm-generic//bitops/const_hweight.h ** - *****************************************/ - -/* count number of 1s in 'w' */ -#define hweight32(w) __builtin_popcount((unsigned)w) - - -/******************** - ** linux/string.h ** - ********************/ - -#include - -int strtobool(const char *, bool *); - - -/***************** - ** linux/nls.h ** - *****************/ - -enum utf16_endian { UTF16_LITTLE_ENDIAN = 1, }; - -int utf16s_to_utf8s(const wchar_t *pwcs, int len, - enum utf16_endian endian, u8 *s, int maxlen); - - -/******************* - ** linux/ctype.h ** - *******************/ - -int isprint(int); - - -/****************** - ** linux/init.h ** - ******************/ - -#include - -#define __initconst -#define __initdata -#define __devinit -#define __devexit -#define __devexit_p(x) x - -#define __exit_p(x) x - - -/******************** - ** linux/module.h ** - ********************/ - -#define MODULE_SOFTDEP(x) - -#define THIS_MODULE 0 - -#define MODULE_DEVICE_TABLE(type, name) - -#undef module_init -#undef module_exit - -#define _MOD_CONCAT(a,b) module_##a##b -#define MOD_CONCAT(a,b) _MOD_CONCAT(a,b) -#define module_init(fn) void MOD_CONCAT(fn, MOD_SUFFIX)(void) { fn(); } -#define module_exit(exit_fn) void MOD_CONCAT(exit_fn, MOD_SUFFIX)(void) { exit_fn(); } - -#define module_driver(__driver, __register, __unregister, ...) \ - static int __init __driver##_init(void) \ - { \ - return __register(&(__driver) , ##__VA_ARGS__); \ - } \ - module_init(__driver##_init); \ - static void __exit __driver##_exit(void) \ - { \ - __unregister(&(__driver) , ##__VA_ARGS__); \ - } \ - module_exit(__driver##_exit); - - -/************************* - ** linux/moduleparam.h ** - *************************/ - -#define module_param_array_named(name, array, type, nump, perm) -#define module_param_string(name, string, len, perm) -#define core_param(name, var, type, perm) - - -/****************** - ** linux/slab.h ** - ******************/ - -enum { - SLAB_HWCACHE_ALIGN = 0x00002000UL, - SLAB_CACHE_DMA = 0x00004000UL, - ARCH_KMALLOC_MINALIGN = 128, -}; - -void *kzalloc(size_t size, gfp_t flags); -void kfree(const void *); -void *kmalloc(size_t size, gfp_t flags); -void *kcalloc(size_t n, size_t size, gfp_t flags); - -/** - * Genode specific for large DMA allocations - */ -void *dma_malloc(size_t size); -void dma_free(void *ptr); - -struct kmem_cache; - -/** - * Create slab cache - */ -struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, - unsigned long, void (*)(void *)); - -/** - * Destroy slab cache - */ -void kmem_cache_destroy(struct kmem_cache *); - -/** - * Alloc from cache - */ -void *kmem_cache_alloc(struct kmem_cache *, gfp_t); - -/** - * Allocate and zero slab - */ -void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags); - -/** - * Free slab - */ -void kmem_cache_free(struct kmem_cache *, void *); - - -void *kmalloc_array(size_t n, size_t size, gfp_t flags); - - -/********************** - ** linux/spinlock.h ** - **********************/ - -#include - - -/******************* - ** linux/mutex.h ** - *******************/ - -#include - -LX_MUTEX_INIT_DECLARE(hid_open_mut); -LX_MUTEX_INIT_DECLARE(host_cmd_pool_mutex); -LX_MUTEX_INIT_DECLARE(input_mutex); -LX_MUTEX_INIT_DECLARE(usb_bus_list_lock); -LX_MUTEX_INIT_DECLARE(usb_port_peer_mutex); -LX_MUTEX_INIT_DECLARE(usbfs_mutex); -LX_MUTEX_INIT_DECLARE(wacom_udev_list_lock); - -#define hid_open_mut LX_MUTEX(hid_open_mut) -#define host_cmd_pool_mutex LX_MUTEX(host_cmd_pool_mutex) -#define input_mutex LX_MUTEX(input_mutex) -#define usb_bus_list_lock LX_MUTEX(usb_bus_list_lock) -#define usb_port_peer_mutex LX_MUTEX(usb_port_peer_mutex) -#define usbfs_mutex LX_MUTEX(usbfs_mutex) -#define wacom_udev_list_lock LX_MUTEX(wacom_udev_list_lock) - -int mutex_lock_interruptible(struct mutex *m); - - -/*********************** - ** linux/semaphore.h ** - ***********************/ - -struct semaphore; - -void down(struct semaphore *sem); - - -/******************* - ** linux/rwsem.h ** - *******************/ - -#include - - -/****************** - ** linux/time.h ** - ******************/ - -#include - -enum { CLOCK_BOOTTIME = 7, }; - - -/************************* - ** linux/timekeeping.h ** - *************************/ - -enum tk_offsets { - TK_OFFS_BOOT = 1, -}; - -ktime_t ktime_get_boottime(void); -ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs); -ktime_t ktime_mono_to_real(ktime_t mono); - - -/******************* - ** linux/timer.h ** - *******************/ - -#include - -#define from_timer(var, callback_timer, timer_fieldname) \ - container_of(callback_timer, typeof(*var), timer_fieldname) - -void setup_timer(struct timer_list *timer, void (*function)(unsigned long), - unsigned long data); -void init_timer(struct timer_list *); -void set_timer_slack(struct timer_list *, int); - -/******************* - ** linux/delay.h ** - *******************/ - -void msleep(unsigned int msecs); -void udelay(unsigned long usecs); -void mdelay(unsigned long usecs); - -void usleep_range(unsigned long min, unsigned long max); - -extern unsigned long loops_per_jiffy; /* needed by 'dwc_otg_attr.c' */ - - -/*********************** - ** linux/workquque.h ** - ***********************/ - -#include - -#define wait_queue_t wait_queue_entry_t - -enum { - WORK_STRUCT_PENDING_BIT = 0, -}; - - -#define work_data_bits(work) ((unsigned long *)(&(work)->data)) - -#define work_pending(work) \ - test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) - -#define delayed_work_pending(w) \ - work_pending(&(w)->work) - -/* dummy for queue_delayed_work call in storage/usb.c */ -#define system_freezable_wq 0 - -extern struct workqueue_struct *system_power_efficient_wq; - - -/****************** - ** linux/wait.h ** - ******************/ - -#define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) DECLARE_WAIT_QUEUE_HEAD(name) - -extern wait_queue_t wait; -void breakpoint(); - - -#define wait_event_interruptible_timeout(wq, condition, timeout) \ -({ \ - _wait_event_timeout(wq, condition, timeout); \ - 1; \ -}) - - -/******************* - ** linux/sched.h ** - *******************/ - -enum { TASK_RUNNING = 0, TASK_INTERRUPTIBLE = 1, TASK_UNINTERRUPTIBLE = 2, TASK_NORMAL = 3 }; - -enum { MAX_SCHEDULE_TIMEOUT = (~0U >> 1) }; - -struct task_struct { - char comm[16]; /* needed by usb/core/devio.c, only for debug output */ -}; - -struct cred; -struct siginfo; -struct pid; - -int kill_pid_info_as_cred(int, struct siginfo *, struct pid *, - const struct cred *, u32); -pid_t task_pid_nr(struct task_struct *tsk); - -struct pid *task_pid(struct task_struct *task); - -void __set_current_state(int state); -#define set_current_state(state) __set_current_state(state) -int signal_pending(struct task_struct *p); -void schedule(void); -signed long schedule_timeout(signed long); -signed long schedule_timeout_uninterruptible(signed long timeout); -void yield(void); - -/* normally defined in asm/current.h, included by sched.h */ -extern struct task_struct *current; - -/* asm/processor.h */ -void cpu_relax(void); - -#define memalloc_noio_save() 0 -#define memalloc_noio_restore(x) - -/********************* - ** linux/kthread.h ** - *********************/ - -int kthread_should_stop(void); -int kthread_stop(struct task_struct *k); - -struct task_struct *kthread_run(int (*)(void *), void *, const char *, ...); - - -/********************** - ** linux/notifier.h ** - **********************/ - -enum { - NOTIFY_DONE = 0x0000, - NOTIFY_OK = 0x0001, - NOTIFY_STOP_MASK = 0x8000, - NOTIFY_BAD = (NOTIFY_STOP_MASK | 0x0002), -}; - -struct notifier_block { - int (*notifier_call)(struct notifier_block *, unsigned long, void *); - struct notifier_block *next; - int priority; -}; - -struct raw_notifier_head -{ - struct notifier_block *head; -}; - -struct atomic_notifier_head { - spinlock_t lock; - struct notifier_block *head; -}; - -struct blocking_notifier_head { - struct rw_semaphore rwsem; - struct notifier_block *head; -}; - -#define BLOCKING_NOTIFIER_INIT(name) { \ - .rwsem = __RWSEM_INITIALIZER((name).rwsem), .head = NULL } -#define BLOCKING_NOTIFIER_HEAD(name) \ - struct blocking_notifier_head name = BLOCKING_NOTIFIER_INIT(name) - -int blocking_notifier_chain_register(struct blocking_notifier_head *nh, - struct notifier_block *nb); -int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, - struct notifier_block *nb); -int blocking_notifier_call_chain(struct blocking_notifier_head *nh, - unsigned long val, void *v); -int atomic_notifier_chain_register(struct atomic_notifier_head *nh, - struct notifier_block *nb); -int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, - struct notifier_block *nb); - - -/************************* - ** linux/scatterlist.h ** - *************************/ - -#include - - -/********************* - ** linux/kobject.h ** - *********************/ - -#include - - -/******************* - ** linux/sysfs.h ** - *******************/ - -struct attribute { - const char *name; - mode_t mode; -}; - -struct kobj_attribute { - struct attribute attr; - void * show; - void * store; -}; - -struct attribute_group { - const char *name; - mode_t (*is_visible)(struct kobject *, struct attribute *, int); - struct attribute **attrs; -}; - -struct file; -struct bin_attribute { - struct attribute attr; - size_t size; - ssize_t (*read)(struct file *, struct kobject *, - struct bin_attribute *, char *, loff_t, size_t); -}; - -#define __ATTR(_name,_mode,_show,_store) { \ - .attr = {.name = #_name, .mode = _mode }, \ - .show = _show, \ - .store = _store, \ -} - -#define __ATTRIBUTE_GROUPS(_name) \ -static const struct attribute_group *_name##_groups[] = { \ - &_name##_group, \ - NULL, \ -} - -#define ATTRIBUTE_GROUPS(_name) \ -static const struct attribute_group _name##_group = { \ - .attrs = _name##_attrs, \ -}; \ -__ATTRIBUTE_GROUPS(_name) - -#define __ATTR_NULL { .attr = { .name = NULL } } -#define __ATTR_RO(name) __ATTR_NULL -#define __ATTR_RW(name) __ATTR_NULL - -static const char* modalias = ""; - -int sysfs_create_group(struct kobject *kobj, - const struct attribute_group *grp); -void sysfs_remove_group(struct kobject *kobj, - const struct attribute_group *grp); -int sysfs_create_link(struct kobject *kobj, struct kobject *target, - const char *name); -void sysfs_remove_link(struct kobject *kobj, const char *name); -int sysfs_create_files(struct kobject *kobj, const struct attribute **ptr); - - -/**************** - ** linux/pm.h ** - ****************/ - -#include - -#define PMSG_AUTO_SUSPEND ((struct pm_message) \ - { .event = PM_EVENT_AUTO_SUSPEND, }) - -/************************ - ** linux/pm_runtime.h ** - ************************/ - -bool pm_runtime_active(struct device *dev); -int pm_runtime_set_active(struct device *dev); -void pm_suspend_ignore_children(struct device *dev, bool enable); -void pm_runtime_enable(struct device *dev); -void pm_runtime_disable(struct device *dev); -void pm_runtime_allow(struct device *dev); -void pm_runtime_forbid(struct device *dev); -void pm_runtime_set_suspended(struct device *dev); -void pm_runtime_get_noresume(struct device *dev); -void pm_runtime_put_noidle(struct device *dev); -void pm_runtime_use_autosuspend(struct device *dev); -int pm_runtime_put_sync_autosuspend(struct device *dev); -void pm_runtime_no_callbacks(struct device *dev); -void pm_runtime_set_autosuspend_delay(struct device *dev, int delay); -int pm_runtime_get_sync(struct device *dev); -int pm_runtime_put_sync(struct device *dev); -int pm_runtime_put(struct device *dev); -int pm_runtime_barrier(struct device *dev); - -/*********************** - ** linux/pm_wakeup.h ** - ***********************/ - -int device_init_wakeup(struct device *dev, bool val); -int device_wakeup_enable(struct device *dev); -bool device_may_wakeup(struct device *dev); -int device_set_wakeup_enable(struct device *dev, bool enable); -bool device_can_wakeup(struct device *dev); - - -/******************** - ** linux/pm_qos.h ** - ********************/ - -enum { PM_QOS_FLAG_NO_POWER_OFF = 1 }; -enum dev_pm_qos_req_type { DEV_PM_QOS_FLAGS = 3 }; - -struct dev_pm_qos_request { unsigned dummy; }; - -int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, - enum dev_pm_qos_req_type type, s32 value); -int dev_pm_qos_remove_request(struct dev_pm_qos_request *req); -int dev_pm_qos_expose_flags(struct device *dev, s32 value); - - -/****************** - ** linux/acpi.h ** - ******************/ - -#define ACPI_PTR(_ptr) (NULL) - - -/******************** - ** linux/device.h ** - ********************/ - -#define dev_info(dev, format, arg...) lx_printf("dev_info: " format, ## arg) -#define dev_warn(dev, format, arg...) lx_printf("dev_warn: " format, ## arg) -#define dev_WARN(dev, format, arg...) lx_printf("dev_WARN: " format, ## arg) -#define dev_err( dev, format, arg...) lx_printf("dev_error: " format, ## arg) -#define dev_notice(dev, format, arg...) lx_printf("dev_notice: " format, ## arg) -#define dev_dbg_ratelimited(dev, format, arg...) - -#define dev_WARN_ONCE(dev, condition, format, arg...) ({\ - lx_printf("dev_WARN_ONCE: " format, ## arg); \ - !!condition; \ -}) - -#if DEBUG_LINUX_PRINTK -#define dev_dbg(dev, format, arg...) lx_printf("dev_dbg: " format, ## arg) -#define dev_vdbg(dev, format, arg...) lx_printf("dev_dbg: " format, ## arg) -#define CONFIG_DYNAMIC_DEBUG -#else -#define dev_dbg( dev, format, arg...) -#define dev_vdbg( dev, format, arg...) -#endif - -#define dev_printk(level, dev, format, arg...) \ - lx_printf("dev_printk: " format, ## arg) - -#define dev_warn_ratelimited(dev, format, arg...) \ - lx_printf("dev_warn_ratelimited: " format "\n", ## arg) - -#define dev_warn_once(dev, format, ...) \ - lx_printf("dev_warn_ratelimited: " format "\n", ##__VA_ARGS__) - -enum { - BUS_NOTIFY_ADD_DEVICE = 0x00000001, - BUS_NOTIFY_DEL_DEVICE = 0x00000002, -}; - -struct device_driver; - -struct bus_type { - const char *name; - struct device_attribute *dev_attrs; - const struct attribute_group **dev_groups; - int (*match)(struct device *dev, struct device_driver *drv); - int (*uevent)(struct device *dev, struct kobj_uevent_env *env); - int (*probe)(struct device *dev); - int (*remove)(struct device *dev); -}; - -struct device_driver { - char const *name; - struct bus_type *bus; - struct module *owner; - const char *mod_name; - const struct of_device_id *of_match_table; - const struct acpi_device_id *acpi_match_table; - int (*probe) (struct device *dev); - int (*remove) (struct device *dev); - - const struct dev_pm_ops *pm; -}; - -struct kobj_uevent_env; - -struct device_type { - const char *name; - const struct attribute_group **groups; - void (*release)(struct device *dev); - int (*uevent)(struct device *dev, struct kobj_uevent_env *env); - char *(*devnode)(struct device *dev, mode_t *mode, kuid_t *, kgid_t *); - const struct dev_pm_ops *pm; -}; - -struct class -{ - const char *name; - char *(*devnode)(struct device *dev, mode_t *mode); -}; - -struct dma_parms; - -/* DEVICE */ -struct device { - const char *name; - struct device *parent; - struct kobject kobj; - const struct device_type *type; - struct device_driver *driver; - void *platform_data; - u64 _dma_mask_buf; - u64 *dma_mask; /* needed by usb/hcd.h */ - u64 coherent_dma_mask; /* omap driver */ - struct dev_pm_info power; - dev_t devt; - const struct attribute_group **groups; - void (*release)(struct device *dev); - struct bus_type *bus; - struct class *class; - void *driver_data; - struct device_node *of_node; - struct device_dma_parameters *dma_parms; - unsigned ref; -}; - -struct device_attribute { - struct attribute attr; - ssize_t (*show)(struct device *dev, struct device_attribute *attr, - char *buf); - ssize_t (*store)(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count); -}; - -struct driver_attribute { - struct attribute attr; - ssize_t (*show)(struct device_driver *driver, char *buf); - ssize_t (*store)(struct device_driver *driver, const char *buf, - size_t count); -}; - -struct lock_class_key { int dummy; }; - -#define DEVICE_ATTR(_name, _mode, _show, _store) \ -struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) - -#define DEVICE_ATTR_RO(_name) \ -struct device_attribute dev_attr_##_name = __ATTR_RO(_name) - -#define DEVICE_ATTR_RW(_name) \ -struct device_attribute dev_attr_##_name = __ATTR_RW(_name) - -#define DRIVER_ATTR(_name, _mode, _show, _store) \ -struct driver_attribute driver_attr_##_name = \ - __ATTR(_name, _mode, _show, _store) - -#define DRIVER_ATTR_RW(_name) \ -struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) - - -void *dev_get_drvdata(const struct device *dev); -int dev_set_drvdata(struct device *dev, void *data); -int dev_set_name(struct device *dev, const char *name, ...); -const char *dev_name(const struct device *dev); -int dev_to_node(struct device *dev); -void set_dev_node(struct device *dev, int node); - -struct device *device_create(struct class *cls, struct device *parent, - dev_t devt, void *drvdata, - const char *fmt, ...); -int device_add(struct device *dev); -void device_destroy(struct class *cls, dev_t devt); -int device_register(struct device *dev); -void device_unregister(struct device *dev); -void device_lock(struct device *dev); -int device_trylock(struct device *dev); -void device_unlock(struct device *dev); -void device_del(struct device *dev); -void device_initialize(struct device *dev); -int device_attach(struct device *dev); -int device_is_registered(struct device *dev); -int device_bind_driver(struct device *dev); -void device_release_driver(struct device *dev); -void device_enable_async_suspend(struct device *dev); -void device_set_wakeup_capable(struct device *dev, bool capable); -int device_create_bin_file(struct device *dev, - const struct bin_attribute *attr); -void device_remove_bin_file(struct device *dev, - const struct bin_attribute *attr); -int device_create_file(struct device *device, - const struct device_attribute *entry); -void device_remove_file(struct device *dev, - const struct device_attribute *attr); -int device_for_each_child(struct device *dev, void *data, - int (*fn)(struct device *dev, void *data)); - - -void put_device(struct device *dev); -struct device *get_device(struct device *dev); - -int driver_register(struct device_driver *drv); -void driver_unregister(struct device_driver *drv); -int driver_attach(struct device_driver *drv); -int driver_create_file(struct device_driver *driver, - const struct driver_attribute *attr); -void driver_remove_file(struct device_driver *driver, - const struct driver_attribute *attr); - -struct device_driver *get_driver(struct device_driver *drv); -void put_driver(struct device_driver *drv); - -struct device *bus_find_device(struct bus_type *bus, struct device *start, - void *data, - int (*match)(struct device *dev, void *data)); -int bus_register(struct bus_type *bus); -void bus_unregister(struct bus_type *bus); -int bus_register_notifier(struct bus_type *bus, - struct notifier_block *nb); -int bus_unregister_notifier(struct bus_type *bus, - struct notifier_block *nb); -int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, - int (*fn)(struct device *dev, void *data)); - -struct class *__class_create(struct module *owner, - const char *name, - struct lock_class_key *key); -#define class_create(owner, name) \ -({ \ - static struct lock_class_key __key; \ - __class_create(owner, name, &__key); \ -}) -int class_register(struct class *cls); -void class_unregister(struct class *cls); -void class_destroy(struct class *cls); - -typedef void (*dr_release_t)(struct device *dev, void *res); -typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); - -void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp); -void devres_add(struct device *dev, void *res); -int devres_destroy(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data); -void devres_free(void *res); - -void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp); - -struct resource; - -void *devm_ioremap_resource(struct device *dev, struct resource *res); - -void devm_kfree(struct device *dev, void *p); - -void *dev_get_platdata(const struct device *dev); - - -/***************************** - ** linux/platform_device.h ** - *****************************/ - -struct platform_device; -void *platform_get_drvdata(const struct platform_device *pdev); -void platform_set_drvdata(struct platform_device *pdev, void *data); - -/* needed by 'dwc_otg_driver.c' */ -struct platform_driver; -void platform_driver_unregister(struct platform_driver *); - - -/********************* - ** linux/dmapool.h ** - *********************/ - -struct dma_pool; - -/* - * Needed by usb/core/buffer.c - */ -struct dma_pool *dma_pool_create(const char *, struct device *, size_t, - size_t, size_t); -void dma_pool_destroy(struct dma_pool *); -void *dma_pool_alloc(struct dma_pool *, gfp_t, dma_addr_t *); -void dma_pool_free(struct dma_pool *, void *, dma_addr_t); - - -/* - * Actually defined in asm-generic/dma-mapping-broken.h - */ -void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t); -void dma_free_coherent(struct device *, size_t, void *, dma_addr_t); - - -/************************* - ** linux/dma-mapping.h ** - *************************/ - -#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) -static inline int dma_set_coherent_mask(struct device *dev, u64 mask) { dev->coherent_dma_mask = mask; return 0; } -static inline int dma_set_mask(struct device *dev, u64 mask) { *dev->dma_mask = mask; return 0; } - -static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask) -{ - dma_set_mask(dev, mask); - return dma_set_coherent_mask(dev, mask); -} - -static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) -{ - dma_set_mask(dev, mask); - dma_set_coherent_mask(dev, mask); - return 0; -} - -/********************* - ** linux/uaccess.h ** - *********************/ - -enum { VERIFY_READ = 0, VERIFY_WRITE = 1 }; - -bool access_ok(int access, void *addr, size_t size); - -size_t copy_from_user(void *to, void const *from, size_t len); -size_t copy_to_user(void *dst, void const *src, size_t len); - -#define get_user(x, ptr) ({ lx_printf("get_user not implemented"); (0);}) -#define put_user(x, ptr) ({ lx_printf("put_user not implemented"); (0);}) - - -unsigned long clear_user(void *to, unsigned long n); - - -/***************** - ** linux/dmi.h ** - *****************/ - -struct dmi_system_id; - -static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; } -static inline const char * dmi_get_system_info(int field) { return NULL; } - - -/***************************** - ** linux/mod_devicetable.h ** - *****************************/ - -/* - * Deal with C++ keyword used as member name of 'pci_device_id' - */ -#define USB_DEVICE_ID_MATCH_VENDOR 0x0001 -#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002 -#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004 -#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008 -#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010 -#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020 -#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040 -#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080 -#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 -#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 - -/******************** - ** linux/dcache.h ** - ********************/ - -#define __read_mostly - -enum dentry_d_lock_class -{ - DENTRY_D_LOCK_NESTED -}; - -struct qstr { - const unsigned char *name; -}; - -struct dentry { - struct inode *d_inode; - struct qstr d_name; - struct list_head d_subdirs; - spinlock_t d_lock; - struct dentry *d_parent; - union { struct list_head d_child; } d_u; -}; - -void d_instantiate(struct dentry *, struct inode *); -int d_unhashed(struct dentry *dentry); -void d_delete(struct dentry *); -struct dentry *d_alloc_root(struct inode *); -struct dentry *dget(struct dentry *dentry); -void dput(struct dentry *); - -void dont_mount(struct dentry *dentry); - - -/****************** - ** linux/poll.h ** - ******************/ - -/* needed by usb/core/devices.c, defined in asm-generic/poll.h */ -#define POLLIN 0x0001 -#define POLLOUT 0x0004 -#define POLLERR 0x0008 -#define POLLHUP 0x0010 -#define POLLRDNORM 0x0040 -#define POLLWRNORM 0x0100 - -typedef struct poll_table_struct { int dummy; } poll_table; - -struct file; - -void poll_wait(struct file *, wait_queue_head_t *, poll_table *); - - -/******************** - ** linux/statfs.h ** - ********************/ - -struct kstatfs; -loff_t default_llseek(struct file *file, loff_t offset, int origin); - - -/************************* - ** asm-generic/fcntl.h ** - *************************/ - -enum { O_NONBLOCK = 0x4000 }; - - -/**************** - ** linux/fs.h ** - ****************/ - -#define FMODE_WRITE 0x2 - -enum { S_DEAD = 16 }; - -enum inode_i_mutex_lock_class { I_MUTEX_PARENT }; - -struct path { - struct dentry *dentry; -}; - -struct file { - u64 f_version; - loff_t f_pos; - struct dentry *f_dentry; - struct path f_path; - unsigned int f_flags; - fmode_t f_mode; - const struct file_operations *f_op; - void *private_data; -}; - -typedef unsigned fl_owner_t; - -struct file_operations { - struct module *owner; - int (*open) (struct inode *, struct file *); - ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); - loff_t (*llseek) (struct file *, loff_t, int); - unsigned int (*poll) (struct file *, struct poll_table_struct *); - long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); - int (*flush) (struct file *, fl_owner_t id); - int (*release) (struct inode *, struct file *); - ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); - int (*fasync) (int, struct file *, int); -}; - -struct inode_operations { int dummy; }; - -struct inode { - umode_t i_mode; - struct mutex i_mutex; - dev_t i_rdev; - struct timespec i_mtime; - struct timespec i_atime; - struct timespec i_ctime; - uid_t i_uid; - gid_t i_gid; - unsigned long i_ino; - const struct file_operations *i_fop; - const struct inode_operations *i_op; - struct super_block *i_sb; - unsigned int i_flags; - loff_t i_size; - union { - struct cdev *i_cdev; - }; - void *i_private; -}; - -struct seq_file; -struct vfsmount; -struct super_operations { - int (*show_options)(struct seq_file *, struct vfsmount *); - int (*drop_inode) (struct inode *); - int (*remount_fs) (struct super_block *, int *, char *); - int (*statfs) (struct dentry *, struct kstatfs *); -}; - -struct super_block { - struct dentry *s_root; - const struct super_operations *s_op; - u32 s_time_gran; - unsigned long s_magic; - unsigned char s_blocksize_bits; - unsigned long s_blocksize; -}; - -struct file_system_type { - const char *name; - struct module *owner; - struct dentry *(*mount)(struct file_system_type *, int, - const char *, void *); - void (*kill_sb)(struct super_block *); -}; - -struct fasync_struct { }; - -unsigned iminor(const struct inode *inode); -unsigned imajor(const struct inode *inode); - -int register_chrdev_region(dev_t, unsigned, const char *); -void unregister_chrdev_region(dev_t, unsigned); -static inline struct file_operations const * -fops_get(struct file_operations const *fops) { return fops; } -void fops_put(struct file_operations const *); -loff_t noop_llseek(struct file *file, loff_t offset, int origin); -int register_chrdev(unsigned int major, const char *name, - const struct file_operations *fops); -void unregister_chrdev(unsigned int major, const char *name); -struct inode *new_inode(struct super_block *sb); -unsigned int get_next_ino(void); -void init_special_inode(struct inode *, umode_t, dev_t); -int generic_delete_inode(struct inode *inode); -void drop_nlink(struct inode *inode); -void inc_nlink(struct inode *inode); -void dentry_unhash(struct dentry *dentry); -void iput(struct inode *); -struct dentry *mount_single(struct file_system_type *fs_type, - int flags, void *data, - int (*fill_super)(struct super_block *, - void *, int)); -int nonseekable_open(struct inode *inode, struct file *filp); -int simple_statfs(struct dentry *, struct kstatfs *); -int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); -ssize_t simple_read_from_buffer(void __user *to, size_t count, - loff_t *ppos, const void *from, size_t available); -void simple_release_fs(struct vfsmount **mount, int *count); -void kill_litter_super(struct super_block *sb); -int register_filesystem(struct file_system_type *); -int unregister_filesystem(struct file_system_type *); - -void kill_fasync(struct fasync_struct **, int, int); -int fasync_helper(int, struct file *, int, struct fasync_struct **); - -extern const struct file_operations simple_dir_operations; -extern const struct inode_operations simple_dir_inode_operations; - -static inline loff_t no_llseek(struct file *file, loff_t offset, int origin) { - return -ESPIPE; } - -struct inode *file_inode(struct file *f); - -#define replace_fops(f, fops) \ -do { \ - struct file *__file = (f); \ - fops_put(__file->f_op); \ - BUG_ON(!(__file->f_op = (fops))); \ -} while(0) - -/******************* - ** linux/namei.h ** - *******************/ - -struct dentry *lookup_one_len(const char *, struct dentry *, int); - - -/******************* - ** linux/mount.h ** - *******************/ - -struct vfsmount { - int dummy; - struct super_block *mnt_sb; -}; - - -/************************* - ** asm-/signal.h ** - *************************/ - -enum { SIGIO = 29 }; - - -/********************** - ** linux/seq_file.h ** - **********************/ - -struct seq_file { int dummy; }; - -int seq_printf(struct seq_file *, const char *, ...); -int seq_putc(struct seq_file *, char); - -/***************** - ** linux/gfp.h ** - *****************/ - -#include - -enum { - GFP_NOIO = GFP_LX_DMA, -}; - -unsigned long get_zeroed_page(gfp_t gfp_mask); -unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); -#define __get_free_page(gfp_mask) __get_free_pages((gfp_mask), 0) - -void __free_pages(struct page *p, unsigned int order); -#define __free_page(p) __free_pages((p), 0) - -void free_pages(unsigned long addr, unsigned int order); -#define free_page(addr) free_pages((addr), 0) - - -/********************* - ** linux/proc_fs.h ** - *********************/ - -struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); -void remove_proc_entry(const char *name, struct proc_dir_entry *parent); - - -/******************** - * linux/debugfs.h ** - ********************/ - -struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); -struct dentry *debugfs_create_file(const char *name, mode_t mode, - struct dentry *parent, void *data, - const struct file_operations *fops); -void debugfs_remove(struct dentry *dentry); -static inline void debugfs_remove_recursive(struct dentry *dentry) { } - - -/************************ - ** linux/page-flags.h ** - ************************/ - -bool is_highmem(void *); -#define PageHighMem(__p) is_highmem(page_zone(__p)) - - -/**************** - ** linux/mm.h ** - ****************/ - -struct zone *page_zone(const struct page *page); -int is_vmalloc_addr(const void *x); -void kvfree(const void *addr); - -/********************* - ** linux/pagemap.h ** - *********************/ - -enum { PAGE_CACHE_SHIFT = PAGE_SHIFT }; -enum { PAGE_CACHE_SIZE = PAGE_SIZE }; - - -/********************** - ** linux/highmem.h ** - **********************/ - -void *kmap(struct page *page); -void kunmap(struct page *page); - - -/********************** - ** asm-generic/io.h ** - **********************/ - -#include - -void *ioremap(phys_addr_t addr, unsigned long size); -void iounmap(volatile void *addr); -void *devm_ioremap(struct device *dev, resource_size_t offset, - unsigned long size); -void *devm_ioremap_nocache(struct device *dev, resource_size_t offset, - unsigned long size); - -#define ioremap_nocache ioremap - -void *phys_to_virt(unsigned long address); - -void outb(u8 value, u32 port); -void outw(u16 value, u32 port); -void outl(u32 value, u32 port); - -u8 inb(u32 port); -u16 inw(u32 port); -u32 inl(u32 port); - -void native_io_delay(void); - -static inline void outb_p(u8 value, u32 port) { outb(value, port); native_io_delay(); } -static inline void outw_p(u16 value, u32 port) { outw(value, port); native_io_delay(); } -static inline void outl_p(u32 value, u32 port) { outl(value, port); native_io_delay(); } - -static inline u8 inb_p(u8 port) { u8 ret = inb(port); native_io_delay(); return ret; } -static inline u16 inw_p(u16 port) { u16 ret = inw(port); native_io_delay(); return ret; } -static inline u32 inl_p(u32 port) { u32 ret = inl(port); native_io_delay(); return ret; } - - -/******************** - ** linux/ioport.h ** - ********************/ - -#include - - - -/*********************** - ** linux/irqreturn.h ** - ***********************/ - -#include - -/* needed by 'dwc_otg_hcd_linux.c' */ -#define IRQ_RETVAL(x) ((x) != IRQ_NONE) - - -/*********************** - ** linux/interrupt.h ** - ***********************/ - -#define IRQF_SHARED 0x00000080 -#define IRQF_DISABLED 0x00000020 - -void local_irq_enable(void); -void local_irq_disable(void); - -int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, - const char *name, void *dev); - -void free_irq(unsigned int, void *); - - -/***************** - ** linux/irq.h ** - *****************/ - -enum { IRQ_TYPE_LEVEL_LOW = 0x00000008 }; /* needed by 'dwc_otg_driver.c' */ - - -/********************* - ** linux/hardirq.h ** - *********************/ - -/* needed by 'dwc_common_linux.c' */ -int in_irq(); - - -/*************** - ** asm/fiq.h ** - ***************/ - -/* - * Needed by 'dwc_otg_hcd_linux.c' - */ -struct fiq_handler { - char const *name; -}; - -void __FIQ_Branch(unsigned long *regs); - - -/********************* - ** linux/hardirq.h ** - *********************/ - -void synchronize_irq(unsigned int irq); -bool in_interrupt(void); - - -/***************** - ** linux/pci.h ** - *****************/ - - -/* - * Definitions normally found in pci_regs.h - */ -extern struct bus_type pci_bus_type; - -enum { DEVICE_COUNT_RESOURCE = 6 }; - - -/* - * PCI types - */ -struct pci_dev { - unsigned int devfn; - unsigned int irq; - struct resource resource[DEVICE_COUNT_RESOURCE]; - struct pci_bus *bus; - unsigned short vendor; - unsigned short device; - unsigned short subsystem_vendor; - unsigned short subsystem_device; - unsigned int class; - u8 revision; - u8 pcie_cap; - u16 pcie_flags_reg; - struct device dev; - unsigned current_state; -}; - -struct pci_fixup { - u16 vendor; /* You can use PCI_ANY_ID here of course */ - u16 device; /* You can use PCI_ANY_ID here of course */ - u32 class; /* You can use PCI_ANY_ID here too */ - unsigned int class_shift; /* should be 0, 8, 16 */ - void (*hook)(struct pci_dev *dev); -}; - -#include -#include - -#define PCI_DEVICE_CLASS(dev_class,dev_class_mask) \ - .class = (dev_class), .class_mask = (dev_class_mask), \ - .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \ - .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID - -#define PCI_DEVICE(vend,dev) \ - .vendor = (vend), .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID - -#define PCI_VDEVICE(vendor, device) \ - PCI_VENDOR_ID_##vendor, (device), \ - PCI_ANY_ID, PCI_ANY_ID, 0, 0 - -/* quirks */ -#define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class, \ - class_shift, hook) \ - void __pci_fixup_##hook(void *data) { hook(data); } - -#define for_each_pci_dev(d) printk("for_each_pci_dev called\n"); while(0) - -enum { PCI_ROM_RESOURCE = 6 }; - -/* - * Deal with C++ keyword used as member name of 'pci_dev' - */ -struct msix_entry -{ - u32 vector; - u16 entry; -}; - - -int pci_enable_msix(struct pci_dev *, struct msix_entry *, int); -void pci_disable_msix(struct pci_dev *); -int pci_enable_msix_exact(struct pci_dev *,struct msix_entry *, int); - - -int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); -int pci_set_power_state(struct pci_dev *dev, pci_power_t state); - - - -/********************** - ** linux/irqflags.h ** - **********************/ - -unsigned long local_irq_save(unsigned long flags); -unsigned long local_irq_restore(unsigned long flags); - - -/************************* - ** linux/dma-direction ** - *************************/ - -enum dma_data_direction -{ - DMA_BIDIRECTIONAL = 0, - DMA_TO_DEVICE = 1, - DMA_FROM_DEVICE = 2 -}; - - -/************************* - ** linux/dma-mapping.h ** - *************************/ - -struct dma_attrs; - -dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, - size_t size, - enum dma_data_direction dir, - struct dma_attrs *attrs); - -void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, - size_t size, - enum dma_data_direction dir, - struct dma_attrs *attrs); - -void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction dir, - struct dma_attrs *attrs); - -dma_addr_t dma_map_page(struct device *dev, struct page *page, - size_t offset, size_t size, - enum dma_data_direction dir); - -int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction dir, - struct dma_attrs *attrs); - -#define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL) -#define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL) -#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) -#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL) - -/* linux/dma-mapping-broken.h */ -void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, - enum dma_data_direction direction); -int dma_mapping_error(struct device *dev, dma_addr_t dma_addr); - -/***************** - ** linux/pid.h ** - *****************/ - -struct pid; -void put_pid(struct pid *pid); -struct pid *get_pid(struct pid *pid); - - -/****************** - ** linux/cred.h ** - ******************/ - -struct cred; -void put_cred(struct cred const *); -const struct cred *get_cred(const struct cred *cred); - -#define get_current_cred() 0 - -#define current_fsuid() 0 -#define current_fsgid() 0 - - -/*************************** - ** asm-generic/siginfo.h ** - ***************************/ - -/* needed by usb/core/devio.c */ -struct siginfo { - int si_signo; - int si_errno; - int si_code; - void *si_addr; -}; - -enum { - SI_ASYNCIO = -4, - _P = 2 << 16, - POLL_IN = _P | 1, - POLL_HUP = _P | 6, -}; - - -/********************** - ** linux/security.h ** - **********************/ - -void security_task_getsecid(struct task_struct *p, u32 *secid); - - -/************************* - ** asm-generic/ioctl.h ** - *************************/ - -/* - * Needed by drivers/input/evdev.c, used to calculate ioctl opcodes - */ -#include - - -/****************** - ** linux/cdev.h ** - ******************/ - -struct cdev { struct kobject kobj; }; -void cdev_init(struct cdev *, const struct file_operations *); -int cdev_add(struct cdev *, dev_t, unsigned); -void cdev_del(struct cdev *); - - -/****************** - ** linux/stat.h ** - ******************/ - -#define S_IALLUGO 0007777 - -#define S_IRUGO 00444 -#define S_IXUGO 00111 -#define S_IRWXUGO 00777 - -#include - -/********************* - ** linux/utsname.h ** - *********************/ - -#define __NEW_UTS_LEN 64 - -struct new_utsname { - char sysname[__NEW_UTS_LEN + 1]; - char release[__NEW_UTS_LEN + 1]; -}; - -struct new_utsname *init_utsname(void); -struct new_utsname *utsname(void); - -/********************* - ** linux/freezer.h ** - *********************/ - -void set_freezable(void); -static inline void set_freezable_with_signal(void) {} - -#define wait_event_freezable(wq, cond) wait_event_interruptible(wq, cond) - - -/******************** - ** linux/parser.h ** - ********************/ - -/* - * needed for usb/core/inode.c - */ - -enum { MAX_OPT_ARGS = 3 }; - -struct match_token { - int token; - const char *pattern; -}; - -typedef struct substring { int dummy; } substring_t; - -typedef struct match_token match_table_t[]; - -int match_token(char *, const match_table_t table, substring_t args[]); -int match_int(substring_t *, int *result); -int match_octal(substring_t *, int *result); - - -/************************ - ** linux/completion.h ** - ************************/ - -#include - -struct completion { unsigned int done; void *task; }; -long __wait_completion(struct completion *work, unsigned long timeout);; - - -/******************* - ** linux/input.h ** - *******************/ - -struct input_dev; - -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, 8 * sizeof(long)) - - -/********************* - ** linux/semaphore ** - *********************/ - -struct semaphore { }; -void sema_init(struct semaphore *sem, int val); -int down_trylock(struct semaphore *sem); -void up(struct semaphore *sem); -int down_interruptible(struct semaphore *sem); - - -/*********************** - ** linux/hid-debug.h ** - ***********************/ - -enum { HID_DEBUG_BUFSIZE=512 }; - -#define hid_debug_init() do { } while (0) -#define hid_dump_input(a,b,c) do { } while (0) -#define hid_debug_event(a,b) do { } while (0) -#define hid_debug_register(a, b) do { } while (0) -#define hid_debug_unregister(a) do { } while (0) -#define hid_debug_exit() do { } while (0) -#define hid_dump_report(a, b, c, d) do { } while (0) - - -/****************** - ** linux/list.h ** - ******************/ - -/* - * Important to decl here, otherwise the compiler will generate - * a non-static function and all hell breaks loose. - */ -static inline void barrier(); - -#include - - -/******************** - ** linux/hidraw.h ** - ********************/ - -struct hidraw { u32 minor; }; -struct hid_device; - -static inline int hidraw_init(void) { return 0; } -static inline void hidraw_exit(void) { } -static inline int hidraw_report_event(struct hid_device *hid, u8 *data, int len) { return 0; } -static inline int hidraw_connect(struct hid_device *hid) { return -1; } -static inline void hidraw_disconnect(struct hid_device *hid) { } - - -/********************** - ** linux/rcupdate.h ** - **********************/ - -static inline void rcu_read_lock(void) { } -static inline void rcu_read_unlock(void) { } -static inline void synchronize_rcu(void) { } - -#define rcu_dereference(p) p -#define rcu_assign_pointer(p,v) p = v - -#define rcu_dereference_protected(p, c) p - - -/********************* - ** linux/rculist.h ** - *********************/ - -#define list_for_each_entry_rcu(pos, head, member) \ - list_for_each_entry(pos, head, member) - -static inline void list_add_rcu(struct list_head *n, struct list_head *head) { - list_add(n, head); } - -static inline void list_add_tail_rcu(struct list_head *n, - struct list_head *head) { - list_add_tail(n, head); } - -static inline void list_del_rcu(struct list_head *entry) { - list_del(entry); } - - -/********************* - ** linux/lockdep.h ** - *********************/ - -enum { SINGLE_DEPTH_NESTING = 1 }; - -bool lockdep_is_held(void *); - - -/******************** - ** linux/random.h ** - ********************/ - -static inline void add_input_randomness(unsigned int type, unsigned int code, - unsigned int value) { } -void add_device_randomness(const void *, unsigned int); - -/********************* - ** linux/vmalloc.h ** - *********************/ - -void *vmalloc(unsigned long size); -void *vzalloc(unsigned long size); -void vfree(void *addr); - - -/******************* - ** linux/genhd.h ** - *******************/ - -struct gendisk -{ - void *private_data; -}; - - -/******************** - ** linux/blkdev.h ** - ********************/ - -enum { BLK_BOUNCE_HIGH = -1ULL }; -enum blk_eh_timer_return { DUMMY }; - -#define BLK_MAX_CDB 16 - -#define blk_bidi_rq(rq) ((rq)->next_rq != NULL) - -struct request_queue -{ - spinlock_t *queue_lock; -}; - -enum rq_cmd_type_bits -{ - REQ_TYPE_BLOCK_PC = 2, -}; - -struct request -{ - enum rq_cmd_type_bits cmd_type; - struct gendisk *rq_disk; - void *special; /* opaque pointer available for LLD use */ - struct request *next_rq; -}; - -void blk_queue_bounce_limit(struct request_queue *, u64); -void blk_queue_dma_alignment(struct request_queue *, int); -void blk_queue_max_hw_sectors(struct request_queue *, unsigned int); -int blk_queue_resize_tags(struct request_queue *, int); -int blk_queue_tagged(struct request_queue *); -void blk_queue_update_dma_alignment(struct request_queue *, int); - -void blk_complete_request(struct request *); - -sector_t blk_rq_pos(const struct request *rq); - -unsigned int queue_max_hw_sectors(struct request_queue *q); - - -/******************** - ** linux/blk-mq.h ** - ********************/ - -struct blk_mq_tag_set -{ - unsigned dummy; -}; - - -/************************ - ** scsi/scsci_proto.h ** - ************************/ - -enum { - SAM_STAT_GOOD = 0x00, - SAM_STAT_INTERMEDIATE = 0x10, - SAM_STAT_INTERMEDIATE_CONDITION_MET= 0x14, - SAM_STAT_COMMAND_TERMINATED = 0x22, -}; - -#include - - -/************************* - ** scsi/scsi_devinfo.h ** - *************************/ - -enum Blist { - BLIST_FORCELUN = 2, -}; - - -/******************** - ** scsi/scsi_eh.h ** - *******************/ - -struct scsi_eh_save -{ - unsigned char cmd_len; -}; - -struct scsi_sense_hdr -{ - u8 response_code; - u8 sense_key; - u8 asc; - u8 ascq; - u8 additional_length; /* always 0 for fixed sense format */ -}; - -void scsi_report_device_reset(struct Scsi_Host *, int, int); -void scsi_report_bus_reset(struct Scsi_Host *, int); - -void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, - struct scsi_eh_save *ses, unsigned char *cmnd, - int cmnd_size, unsigned sense_bytes); - -void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, - struct scsi_eh_save *ses); - -int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, - struct scsi_sense_hdr *sshdr); - -const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len, - int desc_type); -int scsi_sense_valid(struct scsi_sense_hdr *); -int scsi_sense_is_deferred(struct scsi_sense_hdr *); - - -/********************* - ** scsi/scsi_tcq.h ** - *********************/ - -enum { - MSG_SIMPLE_TAG = 0x20, - MSG_ORDERED_TAG = 0x22, -}; - - -/*********************** - ** drivers/scsi/sd.h ** - **********************/ - -struct scsi_disk -{ - sector_t capacity; /* size in 512-byte sectors */ -}; - -struct scsi_disk *scsi_disk(struct gendisk *disk); - - -/********************** - ** scsi/scsi_cmnd.h ** - **********************/ - -enum { - MAX_COMMAND_SIZE = 16, - SCSI_SENSE_BUFFERSIZE = 96, -}; - -struct scsi_data_buffer -{ - struct sg_table table; - unsigned length; -}; - -struct scsi_cmnd -{ - struct scsi_device *device; - struct list_head list; /* scsi_cmnd participates in queue lists */ - struct delayed_work abort_work; - unsigned long serial_number; - - /* - * This is set to jiffies as it was when the command was first - * allocated. It is used to time how long the command has - * been outstanding - */ - unsigned long jiffies_at_alloc; - - unsigned short cmd_len; - enum dma_data_direction sc_data_direction; - unsigned char *cmnd; - - struct scsi_data_buffer sdb; - struct scsi_data_buffer *prot_sdb; - - unsigned underflow; /* return error if less than - this amount is transferred */ - - struct request *request; /* the command we are working on */ - unsigned char *sense_buffer; /* obtained by REQUEST SENSE when - * CHECK CONDITION is received on original - * command (auto-sense) */ - /** - * Low-level done function - * - * This function can be used by low-level driver to point to completion - * function. Not used by mid/upper level code. - */ - void (*scsi_done) (struct scsi_cmnd *); - - int result; /* status code from lower level driver */ - void *back; /* uur completion */ - - void *packet; - void *session; -}; - - -struct scatterlist *scsi_sglist(struct scsi_cmnd *cmd); -unsigned scsi_sg_count(struct scsi_cmnd *cmd); -unsigned scsi_bufflen(struct scsi_cmnd *cmd); -void scsi_set_resid(struct scsi_cmnd *cmd, int resid); -int scsi_get_resid(struct scsi_cmnd *cmd); - -struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd); -struct scsi_target *scsi_target(struct scsi_device *sdev); - -void trace_scsi_dispatch_cmd_start(struct scsi_cmnd *); -void trace_scsi_dispatch_cmd_error(struct scsi_cmnd *, int); -void trace_scsi_dispatch_cmd_done(struct scsi_cmnd *); - - -/************************ - ** scsi/scsi_device.h ** - ************************/ - -#define scmd_printk(prefix, scmd, fmt, a...) -#define sdev_printk(prefix, sdev, fmt, a...) - -struct scsi_target -{ - struct list_head devices; - struct device dev; - unsigned int channel; - unsigned int id; - unsigned int pdt_1f_for_no_lun:1; /* PDT = 0x1f */ - unsigned int no_report_luns:1; /* Don't use - * REPORT LUNS for scanning. */ - atomic_t target_blocked; - char scsi_level; -}; - -enum scsi_device_state -{ - SDEV_CANCEL = 1, - SDEV_DEL, /* device deleted - * no commands allowed */ -}; - -enum { - SCSI_VPD_PG_LEN = 255, -}; - -struct scsi_device -{ - struct Scsi_Host *host; - struct request_queue *request_queue; - - struct list_head siblings; /* list of all devices on this host */ - struct list_head same_target_siblings; /* just the devices sharing same target id */ - - spinlock_t list_lock; - struct list_head cmd_list; /* queue of in use SCSI Command structures */ - - unsigned short queue_depth; /* How deep of a queue we want */ - - unsigned short last_queue_full_depth; /* These two are used by */ - unsigned short last_queue_full_count; /* scsi_track_queue_full() */ - unsigned long last_queue_full_time; /* last queue full time */ - - unsigned int id, channel; - u64 lun; - char type; - char scsi_level; - unsigned char inquiry_len; /* valid bytes in 'inquiry' */ - - int vpd_pg83_len; - unsigned char *vpd_pg83; - int vpd_pg80_len; - unsigned char *vpd_pg80; - struct scsi_target *sdev_target; /* used only for single_lun */ - - unsigned sdev_bflags; - unsigned lockable:1; /* able to prevent media removal */ - unsigned simple_tags:1; /* simple queue tag messages are enabled */ - unsigned ordered_tags:1; /* ordered queue tag messages are enabled */ - unsigned use_10_for_rw:1; /* first try 10-byte read / write */ - unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ - unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */ - unsigned no_write_same:1; /* no WRITE SAME command */ - unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ - unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ - unsigned skip_vpd_pages:1; /* do not read VPD pages */ - unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ - unsigned allow_restart:1; /* issue START_UNIT in error handler */ - unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ - unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ - unsigned no_read_capacity_16:1; /* avoid READ_CAPACITY_16 cmds */ - unsigned retry_hwerror:1; /* retry HARDWARE_ERROR */ - unsigned last_sector_bug:1; /* do not use multisector accesses on - SD_LAST_BUGGY_SECTORS */ - unsigned no_read_disc_info:1; /* avoid READ_DISC_INFO cmds */ - unsigned try_rc_10_first:1; /* Try READ_CAPACACITY_10 first */ - unsigned wce_default_on:1; /* Cache is ON by default */ - unsigned broken_fua:1; /* Don't set FUA bit */ - - atomic_t device_blocked; /* device returned QUEUE_FULL. */ - - atomic_t iorequest_cnt; - struct device sdev_gendev; - enum scsi_device_state sdev_state; -}; - -#define to_scsi_device(d) \ - container_of(d, struct scsi_device, sdev_gendev) - -#define shost_for_each_device(sdev, shost) lx_printf("shost_for_each_device called\n"); -#define __shost_for_each_device(sdev, shost) lx_printf("__shost_for_each_device called\n"); - -int scsi_device_blocked(struct scsi_device *); -int scsi_device_get(struct scsi_device *); -int scsi_execute_req(struct scsi_device *, const unsigned char *, int, void *, - unsigned, struct scsi_sense_hdr *, int , int , int *); - - -/************************ - ** scsi/scsi_driver.h ** - ************************/ - -struct scsi_driver -{ - int (*done)(struct scsi_cmnd *); -}; - - -/************************ - ** Networking support ** - ************************/ - -/********************* - ** linux/if_vlan.h ** - *********************/ - -enum { VLAN_HLEN = 4 }; - -/***************** - ** linux/net.h ** - *****************/ - -int net_ratelimit(void); - -/******************** - ** linux/skbuff.h ** - ********************/ - -struct net_device; - -enum { - CHECKSUM_NONE = 0, - CHECKSUM_UNNECESSARY = 1, - CHECKSUM_COMPLETE = 2, - CHECKSUM_PARTIAL = 3, - - NET_IP_ALIGN = 2, - MAX_SKB_FRAGS = 16, -}; - - -typedef struct skb_frag_struct -{ - struct - { - struct page *p; - } page; - - __u32 page_offset; - __u32 size; -} skb_frag_t; - -struct skb_shared_info -{ - unsigned short nr_frags; - unsigned short gso_size; - - skb_frag_t frags[MAX_SKB_FRAGS]; -}; - -struct sk_buff -{ - struct sk_buff *next; - struct sk_buff *prev; - - /* - * This is the control buffer. It is free to use for every - * layer. Please put your private variables there. If you - * want to keep them across layers you have to do a skb_clone() - * first. This is owned by whoever has the skb queued ATM. - */ - char cb[48] __attribute__((aligned(8))); - - unsigned int len; - union - { - __wsum csum; - struct - { - u16 csum_start; - u16 csum_offset; - }; - }; - u8 local_df:1, - cloned:1, - ip_summed:2, - nohdr:1, - nfctinfo:3; - __be16 protocol; - unsigned char *start; - unsigned char *end; - unsigned char *head; - unsigned char *data; - unsigned char *tail; - unsigned char *phys; - unsigned int truesize; - void *packet; - unsigned char *clone; -}; - -struct sk_buff_head -{ - struct sk_buff *next; - struct sk_buff *prev; - u32 qlen; - spinlock_t lock; -}; - -#define skb_queue_walk(queue, skb) \ - for (skb = (queue)->next; \ - skb != (struct sk_buff *)(queue); \ - skb = skb->next) - -struct skb_shared_info *skb_shinfo(struct sk_buff const *); -struct sk_buff *alloc_skb(unsigned int, gfp_t); -unsigned char *skb_push(struct sk_buff *, unsigned int); -unsigned char *skb_pull(struct sk_buff *, unsigned int); -unsigned char *skb_put(struct sk_buff *, unsigned int); -unsigned char *__skb_put(struct sk_buff *, unsigned int); -void skb_trim(struct sk_buff *, unsigned int); -unsigned int skb_headroom(const struct sk_buff *); -int skb_checksum_start_offset(const struct sk_buff *); -struct sk_buff *skb_copy_expand(const struct sk_buff *, int, int, gfp_t); -unsigned char *skb_tail_pointer(const struct sk_buff *); -int skb_tailroom(const struct sk_buff *); -void skb_set_tail_pointer(struct sk_buff *, const int); -struct sk_buff *skb_clone(struct sk_buff *, gfp_t); -void skb_reserve(struct sk_buff *, int); -int skb_header_cloned(const struct sk_buff *); -unsigned int skb_headlen(const struct sk_buff *); -int skb_linearize(struct sk_buff *); - - -struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length); - -static inline -struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, - unsigned int length, gfp_t gfp) -{ - return netdev_alloc_skb_ip_align(dev, length); -} - - -static inline int skb_cloned(const struct sk_buff *skb) { - return skb->cloned; } -static inline void skb_copy_to_linear_data(struct sk_buff *skb, - const void *from, - const unsigned int len) { - memcpy(skb->data, from, len); } - -struct sk_buff *skb_dequeue(struct sk_buff_head *); -void skb_queue_head_init(struct sk_buff_head *); -void skb_queue_tail(struct sk_buff_head *, struct sk_buff *); -void __skb_queue_tail(struct sk_buff_head *, struct sk_buff *); -int skb_queue_empty(const struct sk_buff_head *); -void skb_queue_purge(struct sk_buff_head *); -void __skb_unlink(struct sk_buff *, struct sk_buff_head *); - -void skb_tx_timestamp(struct sk_buff *); -bool skb_defer_rx_timestamp(struct sk_buff *); - -void dev_kfree_skb(struct sk_buff *); -void dev_kfree_skb_any(struct sk_buff *); -void kfree_skb(struct sk_buff *); - - -int pskb_expand_head(struct sk_buff *, int, int ntail, gfp_t); - -unsigned int skb_frag_size(const skb_frag_t *frag); - -/********************* - ** linux/uapi/if.h ** - *********************/ - -enum { - IFF_NOARP = 0x80, /* no APR protocol */ - IFF_PROMISC = 0x100, /* receive all packets */ - IFF_ALLMULTI = 0x200, /* receive all multicast packets */ - IFF_MULTICAST = 0x1000, /* supports multicast */ - IFNAMSIZ = 16, -}; - -struct ifreq { }; - - -/********************** - ** linux/if_ether.h ** - **********************/ - -enum { - ETH_ALEN = 6, /* octets in one ethernet addr */ - ETH_HLEN = 14, /* total octets in header */ - ETH_P_8021Q = 0x8100, /* 802.1Q VLAN Extended Header */ - - ETH_FRAME_LEN = 1514, -}; - - -/********************* - ** linux/ethtool.h ** - *********************/ - -enum { - DUPLEX_HALF = 0x0, - DUPLEX_FULL = 0x1, - ETHTOOL_GSET = 0x1, - ETHTOOL_FWVERS_LEN = 32, - ETHTOOL_BUSINFO_LEN = 32, - - WAKE_PHY = 0, - WAKE_UCAST = (1 << 1), - WAKE_MCAST = (1 << 2), - WAKE_BCAST = (1 << 3), - WAKE_ARP = (1 << 4), - WAKE_MAGIC = (1 << 5), - - SPEED_100 = 100, - SPEED_1000 = 1000, - SUPPORTED_100baseT_Full = (1 << 3), - SUPPORTED_1000baseT_Full = (1 << 5), -}; - - -struct ethtool_cmd -{ - u32 cmd; - u16 speed; - u8 duplex; -}; - -struct ethtool_regs -{ - u32 version; -}; - -struct ethtool_eeprom -{ - u32 magic; - u32 offset; - u32 len; -}; - -struct ethtool_drvinfo -{ - char driver[32]; /* driver short name, "tulip", "eepro100" */ - char version[32]; /* driver version string */ - char fw_version[ETHTOOL_FWVERS_LEN]; /* firmware version string */ - char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */ - /* For PCI devices, use pci_name(pci_dev). */ - u32 eedump_len; -}; - -struct ethtool_wolinfo { - u32 supported; - u32 wolopts; -}; - -struct ethhdr { }; -struct ethtool_ts_info; - -struct ethtool_eee -{ - u32 supported; - u32 advertised; - u32 lp_advertised; - u32 eee_active; - u32 eee_enabled; -}; - - -struct ethtool_ops -{ - int (*get_settings)(struct net_device *, struct ethtool_cmd *); - int (*set_settings)(struct net_device *, struct ethtool_cmd *); - void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); - int (*get_regs_len)(struct net_device *); - void (*get_regs)(struct net_device *, struct ethtool_regs *, void *); - int (*nway_reset)(struct net_device *); - u32 (*get_link)(struct net_device *); - int (*get_eeprom_len)(struct net_device *); - int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); - int (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); - u32 (*get_msglevel)(struct net_device *); - void (*set_msglevel)(struct net_device *, u32); - void (*get_wol)(struct net_device *, struct ethtool_wolinfo *); - int (*set_wol)(struct net_device *, struct ethtool_wolinfo *); - int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *); - int (*get_eee)(struct net_device *, struct ethtool_eee *); - int (*set_eee)(struct net_device *, struct ethtool_eee *); -}; - -__u32 ethtool_cmd_speed(const struct ethtool_cmd *); -u32 ethtool_op_get_link(struct net_device *); -int ethtool_op_get_ts_info(struct net_device *, struct ethtool_ts_info *); - - -/*********************** - ** linux/netdevice.h ** - ***********************/ - -#include - -#define netif_err(priv, type, dev, fmt, args...) lx_printf("netif_err: " fmt, ## args); -#define netif_info(priv, type, dev, fmt, args...) lx_printf("netif_info: " fmt, ## args); - -#define netdev_err(dev, fmt, args...) lx_printf("nedev_err: " fmt, ##args) -#define netdev_warn(dev, fmt, args...) lx_printf("nedev_warn: " fmt, ##args) -#define netdev_info(dev, fmt, args...) lx_printf("nedev_info: " fmt, ##args) - -#define netdev_for_each_mc_addr(a, b) if (0) - -#if DEBUG_LINUX_PRINTK -#define netif_dbg(priv, type, dev, fmt, args...) lx_printf("netif_dbg: " fmt, ## args) -#define netdev_dbg(dev, fmt, args...) lx_printf("netdev_dbg: " fmt, ##args) -#else -#define netif_dbg(priv, type, dev, fmt, args...) -#define netdev_dbg(dev, fmt, args...) -#endif - -#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev)) -#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype)) - -enum netdev_tx { NETDEV_TX_OK = 0 }; -typedef enum netdev_tx netdev_tx_t; - -enum { - MAX_ADDR_LEN = 32, - NET_RX_SUCCESS = 0, - NET_ADDR_RANDOM = 1, - - NETIF_MSG_DRV = 0x1, - NETIF_MSG_PROBE = 0x2, - NETIF_MSG_LINK = 0x4, -}; - -struct net_device_ops -{ - int (*ndo_open)(struct net_device *dev); - int (*ndo_stop)(struct net_device *dev); - netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb, struct net_device *dev); - void (*ndo_set_rx_mode)(struct net_device *dev); - int (*ndo_set_mac_address)(struct net_device *dev, void *addr); - int (*ndo_validate_addr)(struct net_device *dev); - int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd); - void (*ndo_tx_timeout) (struct net_device *dev); - int (*ndo_change_mtu)(struct net_device *dev, int new_mtu); - int (*ndo_set_features)(struct net_device *dev, netdev_features_t features); -}; - -struct net_device_stats -{ - unsigned long rx_packets; - unsigned long tx_packets; - unsigned long rx_bytes; - unsigned long tx_bytes; - unsigned long rx_errors; - unsigned long tx_errors; - unsigned long rx_dropped; - unsigned long tx_dropped; - unsigned long rx_length_errors; - unsigned long rx_over_errors; - unsigned long rx_crc_errors; - unsigned long rx_frame_errors; -}; - -/* NET_DEVICE */ -struct net_device -{ - char name[IFNAMSIZ]; - u32 features; - u32 hw_features; - - struct net_device_stats stats; - const struct net_device_ops *netdev_ops; - const struct ethtool_ops *ethtool_ops; - - unsigned long state; - - unsigned int flags; - unsigned short hard_header_len; /* hardware hdr length */ - unsigned int mtu; - unsigned short needed_headroom; - unsigned short needed_tailroom; - unsigned char perm_addr[MAX_ADDR_LEN]; - unsigned char addr_assign_type; - unsigned char *dev_addr; - unsigned char _dev_addr[ETH_ALEN]; - unsigned long trans_start; /* Time (in jiffies) of last Tx */ - int watchdog_timeo; /* used by dev_watchdog() */ - struct device dev; - void *priv; - unsigned net_ip_align; - - struct phy_device *phydev; -}; - - -struct netdev_hw_addr -{ - unsigned char addr[MAX_ADDR_LEN]; -}; - -enum netdev_state_t { - __LINK_STATE_START, - __LINK_STATE_PRESENT, - __LINK_STATE_NOCARRIER, - __LINK_STATE_LINKWATCH_PENDING, - __LINK_STATE_DORMANT, -}; - -#define netif_msg_tx_err(p) ({ printk("netif_msg_tx_err called not implemented\n"); 0; }) -#define netif_msg_rx_err(p) ({ printk("netif_msg_rx_err called not implemented\n"); 0; }) -#define netif_msg_tx_queued(p) ({ printk("netif_msg_tx_queued called not implemented\n"); 0; }) - -u32 netif_msg_init(int, int); - -static inline void *netdev_priv(const struct net_device *dev) { return dev->priv; } - -int netif_running(const struct net_device *); -int netif_carrier_ok(const struct net_device *dev); -int netif_device_present(struct net_device *); - -void netif_carrier_on(struct net_device *dev); -void netif_carrier_off(struct net_device *dev); - -void netif_device_detach(struct net_device *); -void netif_start_queue(struct net_device *); -void netif_stop_queue(struct net_device *); -void netif_wake_queue(struct net_device *); -void netif_device_attach(struct net_device *); -void unregister_netdev(struct net_device *); -void free_netdev(struct net_device *); -int netif_rx(struct sk_buff *); -void netif_tx_wake_all_queues(struct net_device *); - -int netdev_mc_empty(struct net_device *); -unsigned netdev_mc_count(struct net_device * dev); -int register_netdev(struct net_device *); - -/***************** - ** linux/mii.h ** - *****************/ - -enum { - FLOW_CTRL_TX = 0x1, - FLOW_CTRL_RX = 0x2, - - MII_BMCR = 0x0, - MII_BMSR = 0x1, - MII_PHYSID1 = 0x2, - MII_PHYSID2 = 0x3, - MII_ADVERTISE = 0x4, - MII_LPA = 0x5, - MII_CTRL1000 = 0x9, - MII_MMD_CTRL = 0xd, - MII_MMD_DATA = 0xe, - MII_PHYADDR = 0x19, - - MII_MMD_CTRL_NOINCR = 0x4000, - - BMCR_RESET = 0x8000, /* reset to default state */ - BMCR_ANENABLE = 0x1000, /* enable auto negotiation */ - - BMSR_LSTATUS = 0x4, - - ADVERTISE_PAUSE_CAP = 0x0400, /* try for pause */ - ADVERTISE_CSMA = 0x0001, /* only selector supported */ - ADVERTISE_PAUSE_ASYM = 0x0800, /* try for asymetric pause */ - ADVERTISE_10HALF = 0x0020, - ADVERTISE_10FULL = 0x0040, - ADVERTISE_100HALF = 0x0080, - ADVERTISE_100FULL = 0x0100, - ADVERTISE_1000FULL = 0x0200, - ADVERTISE_ALL = ADVERTISE_10HALF | ADVERTISE_10FULL | - ADVERTISE_100HALF | ADVERTISE_100FULL -}; - -struct mii_if_info -{ - int phy_id; - int phy_id_mask; - int reg_num_mask; - struct net_device *dev; - int (*mdio_read) (struct net_device *dev, int phy_id, int location); - void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val); - - unsigned int supports_gmii : 1; /* are GMII registers supported? */ -}; - - -unsigned int mii_check_media (struct mii_if_info *, unsigned int, - unsigned int); -int mii_ethtool_gset(struct mii_if_info *, struct ethtool_cmd *); -int mii_ethtool_sset(struct mii_if_info *, struct ethtool_cmd *); -u8 mii_resolve_flowctrl_fdx(u16, u16); -int mii_nway_restart (struct mii_if_info *); -int mii_link_ok (struct mii_if_info *); - -struct mii_ioctl_data { }; -int generic_mii_ioctl(struct mii_if_info *, - struct mii_ioctl_data *, int, - unsigned int *); -struct mii_ioctl_data *if_mii(struct ifreq *); - - -/*********************** - ** uapi/linux/mdio.h ** - ***********************/ - -enum { - MDIO_MMD_PCS = 3, - MDIO_MMD_AN = 7, - MDIO_PCS_EEE_ABLE = 20, - MDIO_AN_EEE_ADV = 60, - MDIO_AN_EEE_LPABLE = 61, -}; - - -u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap); -u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv); -u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv); - - -/********************** - ** linux/inerrupt.h ** - **********************/ - -extern struct workqueue_struct *tasklet_wq; - -struct tasklet_struct -{ - void (*func)(unsigned long); - unsigned long data; - unsigned pending; -}; - -void tasklet_schedule(struct tasklet_struct *t); -void tasklet_hi_schedule(struct tasklet_struct *t); -void tasklet_kill(struct tasklet_struct *); -void tasklet_init(struct tasklet_struct *t, void (*)(unsigned long), unsigned long); - - -/************************* - ** linux/etherdevice.h ** - *************************/ - -int eth_mac_addr(struct net_device *, void *); -int eth_validate_addr(struct net_device *); -__be16 eth_type_trans(struct sk_buff *, struct net_device *); -int is_valid_ether_addr(const u8 *); - -void random_ether_addr(u8 *addr); - -struct net_device *alloc_etherdev(int); - -void eth_hw_addr_random(struct net_device *dev); -void eth_random_addr(u8 *addr); - -bool ether_addr_equal(const u8 *addr1, const u8 *addr2); - - -/******************** - ** asm/checksum.h ** - ********************/ - -__wsum csum_partial(const void *, int, __wsum); -__sum16 csum_fold(__wsum); - - -/******************** - ** linux/socket.h ** - ********************/ - -struct sockaddr { - unsigned short sa_family; - char sa_data[14]; -}; - - -/***************** - ** linux/idr.h ** - *****************/ - -#define DEFINE_IDA(name) struct ida name; -struct ida { }; - -int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, - gfp_t gfp_mask); -void ida_simple_remove(struct ida *ida, unsigned int id); - -/******************* - ** linux/async.h ** - *******************/ - -struct async_domain { }; - -#define ASYNC_DOMAIN(name) struct async_domain name = { }; -void async_unregister_domain(struct async_domain *domain); -#define ASYNC_DOMAIN_EXCLUSIVE(_name) - - - -/******************************* - ** uapi/linux/usbdevice_fs.h ** - *******************************/ - -enum { USBDEVFS_HUB_PORTINFO }; - -struct usbdevfs_hub_portinfo -{ - char nports; - char port [127]; -}; - - -/******************** - ** linux/bitmap.h ** - ********************/ - -int bitmap_subset(const unsigned long *, - const unsigned long *, int); - -int bitmap_weight(const unsigned long *src, unsigned int nbits); - -/******************* - ** linux/crc16.h ** - *******************/ - -u16 crc16(u16 crc, const u8 *buffer, size_t len); - - -/******************* - ** linux/crc32.h ** - *******************/ - -u32 ether_crc(int, unsigned char *); - -/******************* - ** linux/birev.h ** - *******************/ - -u16 bitrev16(u16 in); - - -/****************** - ** linux/phy.h ** - ******************/ - -typedef enum { - PHY_INTERFACE_MODE_MII = 1, -} phy_interface_t; - -struct phy; - -int phy_init(struct phy *phy); -int phy_exit(struct phy *phy); - -struct phy *phy_get(struct device *dev, const char *string); -void phy_put(struct phy *phy); - -int phy_power_on(struct phy *phy); -int phy_power_off(struct phy *phy); - -/************************ - ** linux/usb/gadget.h ** - ************************/ - -struct usb_ep { }; -struct usb_request { }; -struct usb_gadget { }; - - -/**************** - ** linux/of.h ** - ****************/ - -bool of_property_read_bool(const struct device_node *np, const char *propname); - - -/********************** - ** linux/property.h ** - **********************/ - -int device_property_read_string(struct device *dev, const char *propname, - const char **val); -bool device_property_read_bool(struct device *dev, const char *propname); -int device_property_read_u8(struct device *dev, const char *propname, u8 *val); -int device_property_read_u32(struct device *dev, const char *propname, u32 *val); - - -/************************ - ** linux/radix-tree.h ** - ************************/ - -#define INIT_RADIX_TREE(root, mask) lx_printf("INIT_RADIX_TREE not impelemnted\n") -struct radix_tree_root { }; -void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index); -int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); -void *radix_tree_delete(struct radix_tree_root *, unsigned long); -int radix_tree_preload(gfp_t gfp_mask); -void radix_tree_preload_end(void); -int radix_tree_maybe_preload(gfp_t gfp_mask); - - -/********************************** - ** Platform specific defintions ** - **********************************/ - -#include - - -/********** - ** misc ** - **********/ - -static inline void dump_stack(void) { } - - - -/** - * Genode's evdev event handler - */ -enum input_event_type { - EVENT_TYPE_PRESS, EVENT_TYPE_RELEASE, /* key press and release */ - EVENT_TYPE_MOTION, /* any type of (pointer) motion */ - EVENT_TYPE_WHEEL, /* mouse scroll wheel */ - EVENT_TYPE_TOUCH /* touchscreen events */ -}; - -struct input_handle; - -/** - * Input event callback - * - * \param type input event type - * \param code key code if type is EVENT_TYPE_PRESS or - * EVENT_TYPE_RELEASE - * \param absolute_x absolute horizontal coordinate if type is - * EVENT_TYPE_MOTION - * \param absolute_y absolute vertical coordinate if type is - * EVENT_TYPE_MOTION - * \param relative_x relative horizontal coordinate if type is - * EVENT_TYPE_MOTION or EVENT_TYPE_WHEEL - * \param relative_y relative vertical coordinate if type is - * EVENT_TYPE_MOTION or EVENT_TYPE_WHEEL - * - * Key codes conform to definitions in os/include/input/event.h, which is C++ - * and therefore not included here. - * - * Relative coordinates are only significant if absolute_x and absolute_y are - * 0. - */ -typedef void (*genode_input_event_cb)(enum input_event_type type, - unsigned code, - int absolute_x, int absolute_y, - int relative_x, int relative_y); - -/** - * Register input handle - * - * \param handler call-back function on input events - * \param res_x pixels of screen (width) - used by usb touch devices - * \param res_y pixels of screen (height) - used by usb touch devices - * - * \return 0 on success; !0 otherwise - */ -void genode_input_register(genode_input_event_cb handler, unsigned long res_x, - unsigned long res_y, bool multitouch); - - -void genode_evdev_event(struct input_handle *handle, unsigned int type, - unsigned int code, int value); - -void start_input_service(void *); - - -/****************** - ** asm/ptrace.h ** - ******************/ - -/* - * Needed by 'dwc_otg_hcd_linux.c' - */ -struct pt_regs { unsigned long dummy; }; - -#define ARM_r8 dummy -#define ARM_r9 dummy -#define ARM_sp dummy -#define ARM_fp dummy - - -/***************** - ** linux/smp.h ** - *****************/ - -typedef void (*smp_call_func_t)(void *info); - -int smp_call_function_single(int cpuid, smp_call_func_t func, void *info, - int wait); - - -/********************* - ** otg_whitelist.h ** - *********************/ - -struct usb_device; -static inline int is_targeted(struct usb_device *dev) { return 0; } - -/************************ - ** linux/tracepoint.h ** - ************************/ - -#define TRACE_EVENT(name, proto, args, struct, assign, print) -#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) -#define DEFINE_EVENT(template, name, proto, args) - -/* needed by drivers/net/wireless/iwlwifi/iwl-devtrace.h */ -#define TP_PROTO(args...) args -#define TP_STRUCT__entry(args...) (args) -#define TP_ARGS(args...) (args) -#define TP_printk(fmt, args...) (fmt "\n" args) -#define TP_fast_assign(args...) (args) - - -/******************* - ** Tracing stuff ** - *******************/ - -static inline void trace_xhci_cmd_completion(void *p1, void *p2) { } -static inline void trace_xhci_address_ctx(void *p1, void *p2, unsigned long v) { } - -static inline void trace_xhci_dbg_init(struct va_format *v) { } -static inline void trace_xhci_dbg_ring_expansion(struct va_format *v) { } -static inline void trace_xhci_dbg_context_change(struct va_format *v) { } -static inline void trace_xhci_dbg_cancel_urb(struct va_format *v) { } -static inline void trace_xhci_dbg_reset_ep(struct va_format *v) { } -static inline void trace_xhci_dbg_quirks(struct va_format *v) { } -static inline void trace_xhci_dbg_address(struct va_format *v) { } - -static inline void trace_dwc3_readl(struct va_format *v) { } -static inline void trace_dwc3_writel(struct va_format *v) { } -static inline void trace_dwc3_core(struct va_format *v) { } - -void backtrace(void); - -#include - -#endif /* _LX_EMUL_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/otg_whitelist.h b/repos/dde_linux/src/drivers/usb/include/otg_whitelist.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/repos/dde_linux/src/drivers/usb/include/platform.h b/repos/dde_linux/src/drivers/usb/include/platform.h deleted file mode 100644 index 44da5412bf..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/platform.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * \brief Platform specific definitions - * \author Sebastian Sumpf - * \date 2012-07-06 - * - * These functions have to be implemented on all supported platforms. - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _PLATFORM_H_ -#define _PLATFORM_H_ - -#include -#include -#include - -#include - -struct Services -{ - - Genode::Env &env; - - /* USB profiles */ - bool hid = false; - bool stor = false; - bool nic = false; - bool raw = false; - - /* Controller types */ - bool uhci = false; /* 1.0 */ - bool ohci = false; - bool ehci = false; /* 2.0 */ - bool xhci = false; /* 3.0 */ - - /* - * Screen resolution used by touch devices to convert touchscreen - * absolute coordinates to screen absolute coordinates - */ - bool multitouch = false; - unsigned long screen_width = 0; - unsigned long screen_height = 0; - - /* report generation */ - bool raw_report_device_list = false; - - Services(Genode::Env &env) : env(env) - { - using namespace Genode; - - Genode::Xml_node config_node = Lx_kit::env().config_rom().xml(); - try { - Genode::Xml_node node_hid = config_node.sub_node("hid"); - hid = true; - - try { - Genode::Xml_node node_screen = node_hid.sub_node("touchscreen"); - node_screen.attribute("width").value(screen_width); - node_screen.attribute("height").value(screen_height); - multitouch = node_screen.attribute_value("multitouch", false); - } catch (...) { - screen_width = screen_height = 0; - log("Could not read screen resolution in config node"); - } - - log("Configured HID screen with ", screen_width, "x", screen_height, - " (multitouch=", multitouch ? "true" : "false", ")"); - } catch (Xml_node::Nonexistent_sub_node) { - log("No config node found - not starting the USB HID (Input) service"); - } - - try { - config_node.sub_node("storage"); - stor = true; - } catch (Xml_node::Nonexistent_sub_node) { - log("No config node found - not starting the USB Storage (Block) service"); - } - - try { - config_node.sub_node("nic"); - nic = true; - } catch (Xml_node::Nonexistent_sub_node) { - log("No config node found - not starting the USB Nic (Network) service"); - } - - try { - Genode::Xml_node node_raw = config_node.sub_node("raw"); - raw = true; - - try { - Genode::Xml_node node_report = node_raw.sub_node("report"); - raw_report_device_list = node_report.attribute_value("devices", false); - } catch (...) { } - } catch (Xml_node::Nonexistent_sub_node) { - log("No config node found - not starting external USB service"); - } - - if (config_node.attribute_value("uhci", false)) { - uhci = true; - log("Enabled UHCI (USB 1.0/1.1) support"); - } - - if (config_node.attribute_value("ohci", false)) { - ohci = true; - log("Enabled OHCI (USB 1.0/1.1) support"); - } - - if (config_node.attribute_value("ehci", false)) { - ehci = true; - log("Enabled EHCI (USB 2.0) support"); - } - - if (config_node.attribute_value("xhci", false)) { - xhci = true; - log("Enabled XHCI (USB 3.0) support"); - } - - if (!(uhci | ohci | ehci | xhci)) - warning("Warning: No USB controllers enabled.\n" - "Use in your 'usb_drv' configuration"); - } -}; - -void backend_alloc_init(Genode::Env &env, Genode::Ram_allocator &ram, Genode::Allocator &alloc); - -void platform_hcd_init(Genode::Env &, Services *services); -Genode::Irq_session_capability platform_irq_activate(int irq); - -#endif /* _PLATFORM_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/signal.h b/repos/dde_linux/src/drivers/usb/include/signal.h deleted file mode 100644 index 70e30b1ea2..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/signal.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * \brief Main-signal receiver and signal-helper functions - * \author Sebastian Sumpf - * \date 2012-05-23 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _SIGNAL_H_ -#define _SIGNAL_H_ - -#include - -#include - -static bool const verbose = false; - -/** - * Helper that holds sender and entrypoint - */ -class Signal_helper -{ - private: - - Genode::Env &_env; - Genode::Signal_transmitter _sender; - - public: - - Signal_helper(Genode::Env &env) : _env(env) { } - - Genode::Entrypoint &ep() { return _env.ep(); } - Genode::Signal_transmitter &sender() { return _sender; } - Genode::Parent &parent() { return _env.parent(); } - Genode::Env &env() { return _env; } - Genode::Ram_allocator &ram() { return _env.ram(); } - Genode::Region_map &rm() { return _env.rm(); } -}; - - -namespace Storage -{ - void init(Genode::Env &env); -} - -namespace Nic -{ - void init(Genode::Env &env); -} - -namespace Raw -{ - void init(Genode::Env &env, bool report_device_list); -} - - -#endif /* _SIGNAL_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/spec/arm/platform/lx_emul.h b/repos/dde_linux/src/drivers/usb/include/spec/arm/platform/lx_emul.h deleted file mode 100644 index ae10903e57..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/spec/arm/platform/lx_emul.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - * \brief Platform specific part of the Linux API emulation - * \author Sebastian Sumpf - * \date 2012-06-18 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _ARM__PLATFORM__LX_EMUL_H_ -#define _ARM__PLATFORM__LX_EMUL_H_ - -#include - -/************************* - ** asm-generic/sizes.h ** - *************************/ - -enum { - SZ_1K = 0x00000400, - SZ_4K = 0x00001000, -}; - -struct platform_device -{ - char *name; - int id; - struct device dev; - u32 num_resources; - struct resource *resource; -}; - - -/********************** - ** linux/usb/ulpi.h ** - **********************/ - -enum { - ULPI_FUNC_CTRL_RESET = (1 << 5), - ULPI_FUNC_CTRL = (1 << 2), -}; - -/* - * Macros for Set and Clear - * See ULPI 1.1 specification to find the registers with Set and Clear offsets - */ - -#define ULPI_SET(a) (a + 1) - - -/***************************** - ** linux/platform_device.h ** - *****************************/ - -#define module_platform_driver(__platform_driver) \ - module_driver(__platform_driver, platform_driver_register, \ - platform_driver_unregister) - -enum { PLATFORM_DEVID_AUTO = -2 }; - -struct platform_driver { - int (*probe)(struct platform_device *); - int (*remove)(struct platform_device *); - void (*shutdown)(struct platform_device *); - int (*suspend)(struct platform_device *, pm_message_t state); - int (*resume)(struct platform_device *); - struct device_driver driver; - const struct platform_device_id *id_table; -}; - -struct resource *platform_get_resource(struct platform_device *, unsigned, unsigned); -struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, const char *); - -int platform_get_irq(struct platform_device *, unsigned int); -int platform_get_irq_byname(struct platform_device *, const char *); - -int platform_driver_register(struct platform_driver *); -int platform_device_register(struct platform_device *); -void platform_device_unregister(struct platform_device *); - -struct platform_device *platform_device_alloc(const char *name, int id); -int platform_device_add_data(struct platform_device *pdev, const void *data, - size_t size); -int platform_device_add_resources(struct platform_device *pdev, - const struct resource *res, unsigned int num); - -int platform_device_add(struct platform_device *pdev); -int platform_device_del(struct platform_device *pdev); - -int platform_device_put(struct platform_device *pdev); - - -#define to_platform_device(x) container_of((x), struct platform_device, dev) - -/********************** - ** asm/generic/io.h ** - **********************/ - -static inline u32 __raw_readl(const volatile void __iomem *addr) -{ - return *(const volatile u32 __force *) addr; -} - -static inline void __raw_writel(u32 b, volatile void __iomem *addr) -{ - *(volatile u32 __force *) addr = b; -} - - -static inline u8 __raw_readb(const volatile void __iomem *addr) -{ - return *(const volatile u8 __force *) addr; -} - -static inline void __raw_writeb(u8 b, volatile void __iomem *addr) -{ - *(volatile u8 __force *) addr = b; -} - - -/******************************** - ** linux/regulator/consumer.h ** - ********************************/ - -struct regulator { }; -int regulator_enable(struct regulator *); -int regulator_disable(struct regulator *); -void regulator_put(struct regulator *regulator); -struct regulator *regulator_get(struct device *dev, const char *id); - -struct regulator *__must_check devm_regulator_get(struct device *dev, - const char *id); - -/******************************************* - ** arch/arm/plat-omap/include/plat/usb.h ** - *******************************************/ - -int omap_usbhs_enable(struct device *dev); -void omap_usbhs_disable(struct device *dev); - - -/***************** - ** linux/clk.h ** - *****************/ - -struct clk *clk_get(struct device *, const char *); -int clk_enable(struct clk *); -void clk_disable(struct clk *); -void clk_put(struct clk *); -struct clk *devm_clk_get(struct device *dev, const char *id); -int clk_prepare_enable(struct clk *); -void clk_disable_unprepare(struct clk *); - - -/****************** - ** linux/gpio.h ** - ******************/ - -enum { GPIOF_OUT_INIT_HIGH = 0x2 }; - -bool gpio_is_valid(int); -void gpio_set_value_cansleep(unsigned, int); -int gpio_request_one(unsigned, unsigned long, const char *); - -int devm_gpio_request_one(struct device *dev, unsigned gpio, - unsigned long flags, const char *label); - - - - -/**************** - ** linux/of.h ** - ****************/ - -#define of_match_ptr(ptr) NULL -#define for_each_available_child_of_node(parent, child) while (0) - - -unsigned of_usb_get_maximum_speed(struct device_node *np); -unsigned of_usb_get_dr_mode(struct device_node *np); -int of_device_is_compatible(const struct device_node *device, const char *); -void of_node_put(struct device_node *node); - -int of_property_read_u32(const struct device_node *np, const char *propname, - u32 *out_value); - - -/************************* - ** linux/of_platform.h ** - *************************/ - -struct of_dev_auxdata; - -int of_platform_populate(struct device_node *, const struct of_device_id *, - const struct of_dev_auxdata *, struct device *); - - -/********************* - ** linux/of_gpio.h ** - *********************/ - -int of_get_named_gpio(struct device_node *, const char *, int); - - -/****************** - ** linux/phy.h ** - ******************/ - -enum { - MII_BUS_ID_SIZE = 17, - PHY_MAX_ADDR = 32, - PHY_POLL = -1, -}; - - -#define PHY_ID_FMT "%s:%02x" - -struct mii_bus -{ - const char *name; - char id[MII_BUS_ID_SIZE]; - int (*read)(struct mii_bus *bus, int phy_id, int regnum); - int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val); - void *priv; - int *irq; -}; - -struct phy_device -{ - int speed; - int duplex; - int link; -}; - -struct mii_bus *mdiobus_alloc(void); -int mdiobus_register(struct mii_bus *bus); -void mdiobus_unregister(struct mii_bus *bus); -void mdiobus_free(struct mii_bus *bus); - -int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd); -void phy_print_status(struct phy_device *phydev); -int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd); -int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd); -void phy_start(struct phy_device *phydev); -int phy_start_aneg(struct phy_device *phydev); -void phy_stop(struct phy_device *phydev); -int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id); -void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id); - - -int genphy_resume(struct phy_device *phydev); - -struct phy_device * phy_connect(struct net_device *dev, const char *bus_id, - void (*handler)(struct net_device *), - phy_interface_t interface); -void phy_disconnect(struct phy_device *phydev); - -struct phy *devm_phy_get(struct device *dev, const char *string); -struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, - const char *con_id); - - -/********************************* - ** linux/usb/usb_phy_generic.h ** - *********************************/ - -#include -#include - -struct usb_phy_generic_platform_data -{ - enum usb_phy_type type; - int gpio_reset; -}; - - - -/******************************* - ** linux/usb/nop-usb-xceiv.h ** - *******************************/ - -struct nop_usb_xceiv_platform_data { int type; }; - - -/******************************* - ** linux/usb/samsung_usb_phy ** - *******************************/ - -enum samsung_usb_phy_type { USB_PHY_TYPE_HOST = 1 }; - - -/*********************** - ** asm/dma-mapping.h ** - ***********************/ - -/* needed by 'dwc_otg_hcd_linux.c' */ -void *dma_to_virt(struct device *dev, dma_addr_t addr); - - -/******************** - ** asm/irqflags.h ** - ********************/ - -void local_fiq_disable(); -void local_fiq_enable(); -unsigned smp_processor_id(void); - -/*************** - ** asm/fiq.h ** - ***************/ - -struct pt_regs; -int claim_fiq(struct fiq_handler *f); -void set_fiq_regs(struct pt_regs const *regs); -void enable_fiq(); -void set_fiq_handler(void *start, unsigned int length); - - -/************************************ - ** /linux/usb/usb_phy_gen_xceiv.h ** - ************************************/ - - -struct usb_phy_gen_xceiv_platform_data -{ - unsigned type; - int gpio_reset; -}; - - -/****************************** - ** linux/usb/xhci_pdriver.h ** - ******************************/ - -struct usb_xhci_pdata { - unsigned usb3_lpm_capable:1; -}; - - -/****************** - ** asm/memory.h ** - ******************/ - -#define __bus_to_virt phys_to_virt - - -/******************************************************** - ** drivers/usb/host/dwc_otg/dwc_otg/dwc_otg_fiq_fsm.h ** - ********************************************************/ - -extern bool fiq_enable, fiq_fsm_enable; - -#endif /* _ARM__PLATFORM__LX_EMUL_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/spec/arm_v6/platform/lx_emul_barrier.h b/repos/dde_linux/src/drivers/usb/include/spec/arm_v6/platform/lx_emul_barrier.h deleted file mode 100644 index dc52c2f4c4..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/spec/arm_v6/platform/lx_emul_barrier.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * \brief ARMv6-specific part of the Linux API emulation - * \author Christian Prochaska - * \date 2014-05-28 - */ - -/* - * Copyright (C) 2014-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _ARMV6__PLATFORM__LX_EMUL_BARRIER_H_ -#define _ARMV6__PLATFORM__LX_EMUL_BARRIER_H_ - - -/******************* - ** asm/barrier.h ** - *******************/ - -#include - -#endif /* _ARMV6__PLATFORM__LX_EMUL_BARRIER_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/spec/arm_v7/platform/lx_emul_barrier.h b/repos/dde_linux/src/drivers/usb/include/spec/arm_v7/platform/lx_emul_barrier.h deleted file mode 100644 index 1ba19373aa..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/spec/arm_v7/platform/lx_emul_barrier.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * \brief ARMv7-specific part of the Linux API emulation - * \author Christian Prochaska - * \date 2014-05-28 - */ - -/* - * Copyright (C) 2014-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _ARMV7__PLATFORM__LX_EMUL_BARRIER_H_ -#define _ARMV7__PLATFORM__LX_EMUL_BARRIER_H_ - - -/******************* - ** asm/barrier.h ** - *******************/ - -#include - -#endif /* _ARMV7__PLATFORM__LX_EMUL_BARRIER_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/spec/foc_rpi/usb_irq.h b/repos/dde_linux/src/drivers/usb/include/spec/foc_rpi/usb_irq.h deleted file mode 100644 index 86e033c6e8..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/spec/foc_rpi/usb_irq.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * \brief USB: DWC-OTG RaspberryPI Interrupt (base-foc) - * \author Reinier Millo Sánchez - * \date 2015-06-21 - */ - -#ifndef _INCLUDE_USB_IRQ_H_ -#define _INCLUDE_USB_IRQ_H_ - -enum{ - DWC_IRQ = 9, -}; - -#endif /* _INCLUDE_USB_IRQ_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/spec/x86/platform/lx_emul.h b/repos/dde_linux/src/drivers/usb/include/spec/x86/platform/lx_emul.h deleted file mode 100644 index bda7a4ab90..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/spec/x86/platform/lx_emul.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * \brief Platform specific part of the Linux API emulation - * \author Sebastian Sumpf - * \date 2012-06-18 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _X86_32__PLATFORM__LX_EMUL_ -#define _X86_32__PLATFORM__LX_EMUL_ - - -/******************* - ** asm/barrier.h ** - *******************/ - -#include - - -struct platform_device -{ - void *data; -}; - - -#define dev_is_pci(d) (1) - -#endif /* _X86_32__PLATFORM__LX_EMUL_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/storage/scsi.h b/repos/dde_linux/src/drivers/usb/include/storage/scsi.h deleted file mode 100644 index 16931042dc..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/storage/scsi.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * \brief SCSI helpers - * \author Sebastian Sumpf - * \date 2012-05-06 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _SCSI_H_ -#define _SCSI_H_ - -struct scsi_cmnd; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Add a SCSI device - * - * \param sdev Device to add - */ -void scsi_add_device(struct scsi_device *sdev); - - -/** - * Alloc data buffer for command - * - * \param size Size of buffer - * \param cmnd Command to assciate buffer - */ -void scsi_alloc_buffer(size_t size, struct scsi_cmnd *cmnd); - - -/** - * Fill command - * - * \param cmnd Command buffer to setup - * \param size Data size - * \param virt Virtual address of buffer - * \param addr DMA address of buffer - */ -void scsi_setup_buffer(struct scsi_cmnd *cmnd, size_t size, void *virt, dma_addr_t addr); - - -/** - * Free data buffer of command - * - * \param cmnd Command - */ -void scsi_free_buffer(struct scsi_cmnd *cmnd); - - -/** - * Get buffer data for command - * - * \param cmnd Command to retrieve buffer pointer - * - * \return Buffer pointer - */ -void *scsi_buffer_data(struct scsi_cmnd *cmnd); - - -/** - * Allocate a SCSI command - * - * \return Allocated command or zero on failure - */ -struct scsi_cmnd *_scsi_alloc_command(); - - -/** - * Free a SCSI command - * - * \param cmnd Command - */ -void _scsi_free_command(struct scsi_cmnd *cmnd); - -#ifdef __cplusplus -} -#endif - -#endif /* _SCSI_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/include/usb_nic_component.h b/repos/dde_linux/src/drivers/usb/include/usb_nic_component.h deleted file mode 100644 index 2bd9426384..0000000000 --- a/repos/dde_linux/src/drivers/usb/include/usb_nic_component.h +++ /dev/null @@ -1,441 +0,0 @@ -/* - * \brief Block-session implementation for network devices - * \author Sebastian Sumpf - * \date 2012-07-05 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _USB_NIC_COMPONENT_H_ -#define _USB_NIC_COMPONENT_H_ - -/* Genode includes */ -#include -#include -#include - -/* Linux emulation environment includes */ -#include -#include -#include -#include -#include - -/* NIC driver includes */ -#include - -namespace Usb_nic { - - using namespace Genode; - using Genode::size_t; - - class Session_component; - struct Device; -}; - - -class Usb_network_session -{ - protected: - - Usb_nic::Device &_device; - - public: - - Usb_network_session(Usb_nic::Device &device) - : - _device { device } - { } - - virtual void link_state_changed() = 0; - - virtual void rx(Genode::addr_t virt, - Genode::size_t size) = 0; -}; - - -struct Usb_nic::Device -{ - Usb_network_session *_session; - - /** - * Transmit data to driver - */ - virtual bool tx(addr_t virt, size_t size) = 0; - - /** - * Return mac address of device - */ - virtual Nic::Mac_address mac_address() = 0; - - /** - * Return current link-state (true if link detected) - */ - virtual bool link_state() = 0; - - /** - * Set session belonging to this driver - */ - void session(Usb_network_session *s) { _session = s; } - - /** - * Check for session - */ - bool session() { return _session != 0; } - - /** - * Alloc an SKB - */ - virtual sk_buff *alloc_skb() = 0; - - /** - * Submit SKB to device - */ - virtual void tx_skb(sk_buff *skb) = 0; - - /** - * Setup SKB with 'data' of 'size', return 'false' if SKB is longer than - * 'end'. - */ - virtual bool skb_fill(struct sk_buff *skb, unsigned char *data, Genode::size_t size, unsigned char *end) = 0; - - /** - * Call driver fixup function on SKB - */ - virtual void tx_fixup(struct sk_buff *skb) = 0; - - /** - * Return true if device supports burst operations - */ - virtual bool burst() = 0; - - Device() : _session(0) { } -}; - - -class Usb_nic::Session_component : public Usb_network_session, - public Nic::Session_component -{ - protected: - - void _send_burst() - { - static sk_buff work_skb; /* dummy skb for fixup calls */ - static Packet_descriptor save; - - sk_buff *skb = nullptr; - unsigned char *ptr = nullptr; - - /* submit received packets to lower layer */ - while (((_tx.sink()->packet_avail() || save.size()) && _tx.sink()->ready_to_ack())) - { - /* alloc skb */ - if (!skb) { - if (!(skb = _device.alloc_skb())) - return; - - ptr = skb->data; - work_skb.data = nullptr; - } - - Packet_descriptor packet = save.size() ? save : _tx.sink()->get_packet(); - save = Packet_descriptor(); - - if (!_device.skb_fill(&work_skb, ptr, packet.size(), skb->end)) { - /* submit batch */ - _device.tx_skb(skb); - skb = nullptr; - save = packet; - continue; - } - - /* copy packet to current data pos */ - try { Genode::memcpy(work_skb.data, _tx.sink()->packet_content(packet), packet.size()); } - catch (Genode::Packet_descriptor::Invalid_packet) { } - /* call fixup on dummy SKB */ - _device.tx_fixup(&work_skb); - /* advance to next slot */ - ptr = work_skb.end; - skb->len += work_skb.truesize; - /* acknowledge to client */ - _tx.sink()->acknowledge_packet(packet); - } - - /* submit last skb */ - if (skb) - _device.tx_skb(skb); - } - - bool _send() - { - if (!_tx.sink()->ready_to_ack()) - return false; - - if (!_tx.sink()->packet_avail()) - return false; - - Genode::Packet_descriptor packet = _tx.sink()->get_packet(); - if (!packet.size() || !_tx.sink()->packet_valid(packet)) { - Genode::warning("Invalid tx packet"); - return true; - } - - bool ret = _device.tx((addr_t)_tx.sink()->packet_content(packet), packet.size()); - _tx.sink()->acknowledge_packet(packet); - - return ret; - } - - void _handle_packet_stream() override - { - while (_rx.source()->ack_avail()) - _rx.source()->release_packet(_rx.source()->get_acked_packet()); - - if (_device.burst()) - _send_burst(); - else - while (_send()); - } - - public: - - /** - * Constructor - */ - Session_component(Genode::size_t const tx_buf_size, - Genode::size_t const rx_buf_size, - Genode::Allocator &rx_block_md_alloc, - Genode::Env &env, - Device &device) - : - Usb_network_session { device }, - Nic::Session_component { tx_buf_size, rx_buf_size, Genode::CACHED, - rx_block_md_alloc, env } - { - _device.session(this); - } - - - /**************************** - ** Nic::Session_component ** - ****************************/ - - Nic::Mac_address mac_address() override { return _device.mac_address(); } - bool link_state() override { return _device.link_state(); } - - - /************************* - ** Usb_network_session ** - *************************/ - - void link_state_changed() override { _link_state_changed(); } - - /** - * Send packet to client (called from driver) - */ - void rx(addr_t virt, size_t size) override - { - _handle_packet_stream(); - - if (!_rx.source()->ready_to_submit()) - return; - - try { - Packet_descriptor p =_rx.source()->alloc_packet(size); - Genode::memcpy(_rx.source()->packet_content(p), (void*)virt, size); - _rx.source()->submit_packet(p); - } catch (...) { - /* drop */ - return; - } - } -}; - -/* - * Shortcut for single-client root component - */ -typedef Genode::Root_component Root_component; - -/** - * Root component, handling new session requests - */ -class Root : public Root_component -{ - private: - - Genode::Env &_env; - Usb_nic::Device &_device; - - protected: - - Usb_nic::Session_component *_create_session(const char *args) - { - using namespace Genode; - using Genode::size_t; - - size_t ram_quota = Arg_string::find_arg(args, "ram_quota" ).ulong_value(0); - size_t tx_buf_size = Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); - size_t rx_buf_size = Arg_string::find_arg(args, "rx_buf_size").ulong_value(0); - - /* deplete ram quota by the memory needed for the session structure */ - size_t session_size = max(4096UL, (unsigned long)sizeof(Usb_nic::Session_component)); - if (ram_quota < session_size) - throw Genode::Insufficient_ram_quota(); - - /* - * Check if donated ram quota suffices for both communication - * buffers and check for overflow - */ - if (tx_buf_size + rx_buf_size < tx_buf_size || - tx_buf_size + rx_buf_size > ram_quota - session_size) { - Genode::error("insufficient 'ram_quota', got ", ram_quota, " need %ld", - tx_buf_size + rx_buf_size + session_size); - throw Genode::Insufficient_ram_quota(); - } - - return new (Root::md_alloc()) - Usb_nic::Session_component(tx_buf_size, rx_buf_size, - Lx::Malloc::mem(), _env, - _device); - } - - public: - - Root(Genode::Env &env, - Genode::Allocator &md_alloc, - Usb_nic::Device &device) - : - Root_component { &env.ep().rpc_ep(), &md_alloc }, - _env { env }, - _device { device } - { } -}; - - -namespace Genode { - - class Uplink_client; -} - - -class Genode::Uplink_client : public Usb_network_session, - public Uplink_client_base -{ - private: - - sk_buff _burst_work_skb { }; - sk_buff *_burst_skb { nullptr }; - unsigned char *_burst_ptr { nullptr }; - - - /************************ - ** Uplink_client_base ** - ************************/ - - Transmit_result - _drv_transmit_pkt(const char *conn_rx_pkt_base, - size_t conn_rx_pkt_size) override - { - if (_device.tx((addr_t)conn_rx_pkt_base, conn_rx_pkt_size) == 0) { - return Transmit_result::ACCEPTED; - } - return Transmit_result::REJECTED; - } - - void _drv_transmit_pkt_burst_prepare() override - { - _burst_skb = nullptr; - _burst_ptr = nullptr; - } - - Burst_result - _drv_transmit_pkt_burst_step(Packet_descriptor const &packet, - char const *packet_base, - Packet_descriptor &save) override - { - /* alloc _burst_skb */ - if (!_burst_skb) { - if (!(_burst_skb = _device.alloc_skb())) - return Burst_result::BURST_FAILED; - - _burst_ptr = _burst_skb->data; - _burst_work_skb.data = nullptr; - } - - if (!_device.skb_fill(&_burst_work_skb, _burst_ptr, packet.size(), _burst_skb->end)) { - - /* submit batch */ - _device.tx_skb(_burst_skb); - _burst_skb = nullptr; - save = packet; - return Burst_result::BURST_CONTINUE; - } - - /* copy packet to current data pos */ - Genode::memcpy(_burst_work_skb.data, packet_base, packet.size()); - - /* call fixup on dummy SKB */ - _device.tx_fixup(&_burst_work_skb); - - /* advance to next slot */ - _burst_ptr = _burst_work_skb.end; - _burst_skb->len += _burst_work_skb.truesize; - - return Burst_result::BURST_SUCCEEDED; - } - - void _drv_transmit_pkt_burst_finish() override - { - /* submit last _burst_skb */ - if (_burst_skb) - _device.tx_skb(_burst_skb); - } - - bool _drv_supports_transmit_pkt_burst() override - { - return _device.burst(); - } - - public: - - Uplink_client(Env &env, - Allocator &alloc, - Usb_nic::Device &device) - : - Usb_network_session { device }, - Uplink_client_base { env, alloc, _device.mac_address() } - { - _device.session(this); - _drv_handle_link_state(_device.link_state()); - } - - - /************************* - ** Usb_network_session ** - *************************/ - - void link_state_changed() override - { - _drv_handle_link_state(_device.link_state()); - } - - void rx(Genode::addr_t virt, - Genode::size_t size) override - { - _drv_rx_handle_pkt( - size, - [&] (void *conn_tx_pkt_base, - size_t &) - { - memcpy(conn_tx_pkt_base, (void *)virt, size); - return Write_result::WRITE_SUCCEEDED; - }); - } -}; - -#endif /* _USB_NIC_COMPONENT_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/input/evdev.cc b/repos/dde_linux/src/drivers/usb/input/evdev.cc deleted file mode 100644 index f5c136ded5..0000000000 --- a/repos/dde_linux/src/drivers/usb/input/evdev.cc +++ /dev/null @@ -1,525 +0,0 @@ -/* - * \brief Input service and event handler - * \author Christian Helmuth - * \author Dirk Vogt - * \author Sebastian Sumpf - * \author Christian Menard - * \author Alexander Boettcher - * \date 2009-04-20 - * - * TODO make this a complete replacement for evdev.c from Linux - * TODO per-device slot handling - * - * The original implementation was in the L4Env from the TUD:OS group - * (l4/pkg/input/lib/src/l4evdev.c). This file was released under the terms of - * the GNU General Public License version 2. - */ - -/* - * Copyright (C) 2009-2017 Genode Labs GmbH - * Copyright (C) 2014 Ksys Labs LLC - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -/* Genode includes */ -#include -#include -#include - -/* LX kit */ -#include -#include - -/* local */ -#include "led_state.h" - -/* Linux includes */ -#include -#include -#include -#include -#include -#include -#include - - -/* Callback function to Genode subsystem */ -static genode_input_event_cb handler; - -static unsigned long screen_x; -static unsigned long screen_y; - -/* - * We only send multi-touch events if enabled. Otherwise emulated pointer events - * are generated. - */ -static bool multi_touch; - -static struct slot -{ - int id; /* current tracking id */ - int x; /* last reported x axis */ - int y; /* last reported y axis */ - int event; /* last reported ABS_MT_ event */ -} slots[16]; - -static int slot = 0; /* store current input slot */ - - -static bool transform(input_dev *dev, int &x, int &y) -{ - if (!screen_x || !screen_y) return true; - - int const min_x_dev = input_abs_get_min(dev, ABS_X); - int const min_y_dev = input_abs_get_min(dev, ABS_Y); - int const max_x_dev = input_abs_get_max(dev, ABS_X); - int const max_y_dev = input_abs_get_max(dev, ABS_Y); - int const max_y_norm = max_y_dev - min_y_dev; - int const max_x_norm = max_x_dev - min_x_dev; - - if (!max_x_norm || !max_y_norm || - x < min_x_dev || y < min_y_dev || x > max_x_dev || y > max_y_dev) { - Genode::warning("ignore input source with coordinates out of range"); - return false; - } - - x = screen_x * (x - min_x_dev) / (max_x_norm); - y = screen_y * (y - min_y_dev) / (max_y_norm); - - return true; -} - - -static void handle_mt_tracking_id(input_dev *dev, int value) -{ - if (value != -1) { - if (slots[slot].id != -1) - Genode::warning("old tracking id in use and got new one"); - - slots[slot].id = value; - return; - } - - /* send end of slot usage event for clients */ - int x = slots[slot].x < 0 ? 0 : slots[slot].x; - int y = slots[slot].y < 0 ? 0 : slots[slot].y; - - if (!transform(dev, x, y)) return; - - if (handler) - handler(EVENT_TYPE_TOUCH, slot, x, y, -1, -1); - - slots[slot].event = slots[slot].x = slots[slot].y = -1; - slots[slot].id = value; -} - - -static void handle_mt_slot(int value) -{ - if ((unsigned)value >= sizeof(slots) / sizeof(slots[0])) { - Genode::warning("drop multi-touch slot id ", value); - return; - } - - slot = value; -} - - -enum Axis { AXIS_X, AXIS_Y }; - -static void handle_absolute_axis(input_dev *dev, unsigned code, int value, Axis axis) -{ - slots[slot].event = code; - - input_event_type type = EVENT_TYPE_MOTION; - - switch (axis) { - case AXIS_X: - type = code == ABS_X ? EVENT_TYPE_MOTION : EVENT_TYPE_TOUCH; - slots[slot].x = value; - break; - case AXIS_Y: - type = code == ABS_Y ? EVENT_TYPE_MOTION : EVENT_TYPE_TOUCH; - slots[slot].y = value; - break; - } - - int x = slots[slot].x; - int y = slots[slot].y; - - if (x == -1 || y == -1) return; - - if (!transform(dev, x, y)) return; - - if (handler) - handler(type, slot, x, y, 0, 0); -} - - -static void handle_absolute(input_dev *dev, unsigned code, int value) -{ - switch (code) { - case ABS_WHEEL: - if (handler) - handler(EVENT_TYPE_WHEEL, 0, 0, 0, 0, value); - return; - - case ABS_X: - if (dev->mt && multi_touch) return; - handle_absolute_axis(dev, code, value, AXIS_X); - return; - - case ABS_MT_POSITION_X: - if (!multi_touch) return; - handle_absolute_axis(dev, code, value, AXIS_X); - return; - - case ABS_Y: - if (dev->mt && multi_touch) return; - handle_absolute_axis(dev, code, value, AXIS_Y); - return; - - case ABS_MT_POSITION_Y: - if (!multi_touch) return; - handle_absolute_axis(dev, code, value, AXIS_Y); - return; - - case ABS_MT_TRACKING_ID: - if (!multi_touch) return; - handle_mt_tracking_id(dev, value); - return; - - case ABS_MT_SLOT: - if (!multi_touch) return; - handle_mt_slot(value); - return; - - case ABS_MT_TOUCH_MAJOR: - case ABS_MT_TOUCH_MINOR: - case ABS_MT_ORIENTATION: - case ABS_MT_TOOL_TYPE: - case ABS_MT_BLOB_ID: - case ABS_MT_PRESSURE: - case ABS_MT_DISTANCE: - case ABS_MT_TOOL_X: - case ABS_MT_TOOL_Y: - /* ignore unused multi-touch events */ - return; - - default: - Genode::warning("unknown absolute event code ", code, " not handled"); - return; - } -} - - -static void handle_relative(unsigned code, int value) -{ - input_event_type type; - int x = 0, y = 0; - - switch (code) { - case REL_X: - type = EVENT_TYPE_MOTION; - x = value; - break; - - case REL_Y: - type = EVENT_TYPE_MOTION; - y = value; - break; - - case REL_HWHEEL: - type = EVENT_TYPE_WHEEL; - x = value; - break; - - case REL_WHEEL: - type = EVENT_TYPE_WHEEL; - y = value; - break; - - default: - Genode::warning("unknown relative event code ", code, " not handled"); - return; - } - - if (handler) - handler(type, 0, 0, 0, x, y); -} - - -static void handle_key(input_dev *dev, unsigned code, int value) -{ - /* no press/release events for multi-touch devices in multi-touch mode */ - if (dev->mt && multi_touch) return; - - /* map BTN_TOUCH to BTN_LEFT */ - if (code == BTN_TOUCH) code = BTN_LEFT; - - input_event_type type; - switch (value) { - case 0: type = EVENT_TYPE_RELEASE; break; - case 1: type = EVENT_TYPE_PRESS; break; - - default: - Genode::warning("unknown key event value ", value, " not handled"); - return; - } - - if (handler) - handler(type, code, 0, 0, 0, 0); -} - - -extern "C" void genode_evdev_event(input_handle *handle, unsigned int type, - unsigned int code, int value) -{ - input_dev *dev = handle->dev; - - /* filter sound events */ - if (test_bit(EV_SND, handle->dev->evbit)) return; - - /* filter input_repeat_key() */ - if ((type == EV_KEY) && (value == 2)) return; - - /* filter EV_SYN and EV_MSC */ - if (type == EV_SYN || type == EV_MSC) return; - - switch (type) { - case EV_KEY: handle_key(dev, code, value); return; - case EV_REL: handle_relative(code, value); return; - case EV_ABS: handle_absolute(dev, code, value); return; - - default: - Genode::warning("unknown event type ", type, " not handled"); - return; - } -} - - -void genode_input_register(genode_input_event_cb h, unsigned long res_x, - unsigned long res_y, bool multitouch) -{ - for (unsigned i = 0; i < sizeof(slots)/sizeof(*slots); ++i) - slots[i].id = slots[i].event = slots[i].x = slots[i].y = -1; - - handler = h; - screen_x = res_x; - screen_y = res_y; - multi_touch = multitouch; -} - - -/*************************** - ** Keyboard LED handling ** - ***************************/ - -class Keyboard_led -{ - private: - - Genode::Registry::Element _reg_elem; - input_dev * const _input_dev; - - usb_interface *_interface() { - return container_of(_input_dev->dev.parent->parent, usb_interface, dev); } - - usb_device *_usb_device() { - return interface_to_usbdev(_interface()); } - - public: - - Keyboard_led(Genode::Registry ®istry, input_dev *dev) - : _reg_elem(registry, *this), _input_dev(dev) { } - - bool match(input_dev const *other) const { return _input_dev == other; } - - void update(unsigned leds) - { - unsigned *buf = (unsigned *)kmalloc(4, GFP_LX_DMA); - *buf = leds; - usb_control_msg(_usb_device(), usb_sndctrlpipe(_usb_device(), 0), - 0x9, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0x200, - _interface()->cur_altsetting->desc.bInterfaceNumber, - buf, 1, 500); - kfree(buf); - } -}; - - -static Genode::Registry _registry; - - -namespace Usb { class Led; } - -class Usb::Led -{ - private: - - Lx::Task _task { _run, this, "led_worker", Lx::Task::PRIORITY_2, - Lx::scheduler() }; - - completion _config_update; - completion _led_update; - - enum Update_state { NONE, UPDATE, BLOCKED }; - Update_state _update_state { NONE }; - - Led_state _capslock { Lx_kit::env().env(), "capslock" }, - _numlock { Lx_kit::env().env(), "numlock" }, - _scrlock { Lx_kit::env().env(), "scrlock" }; - - Genode::Signal_handler _config_handler { - Lx_kit::env().env().ep(), *this, &Led::_handle_config }; - - void _handle_config() - { - Lx_kit::env().config_rom().update(); - Genode::Xml_node config = Lx_kit::env().config_rom().xml(); - - _capslock.update(config, _config_handler); - _numlock .update(config, _config_handler); - _scrlock .update(config, _config_handler); - - complete(&_config_update); - Lx::scheduler().schedule(); - } - - static void _run(void *l) - { - Led *led = (Led *)l; - - while (true) { - /* config update from EP */ - wait_for_completion(&led->_config_update); - - led->_update_state = UPDATE; - - _registry.for_each([&] (Keyboard_led &keyboard) { - led->update(keyboard); }); - - /* wake up other task that waits for regestry access */ - if (led->_update_state == BLOCKED) - complete(&led->_led_update); - - led->_update_state = NONE; - } - } - - public: - - Led() - { - init_completion(&_config_update); - init_completion(&_led_update); - Genode::Signal_transmitter(_config_handler).submit(); - } - - void update(Keyboard_led &keyboard) - { - unsigned leds = 0; - - leds |= _capslock.enabled() ? 1u << LED_CAPSL : 0; - leds |= _numlock.enabled() ? 1u << LED_NUML : 0; - leds |= _scrlock.enabled() ? 1u << LED_SCROLLL : 0; - - keyboard.update(leds); - } - - /* - * wait for completion of registry and led state updates - */ - void wait_for_registry() - { - /* task in _run function might receive multiple updates */ - while ((_update_state == UPDATE)) { - _update_state = BLOCKED; - wait_for_completion(&_led_update); - } - } -}; - - -static Genode::Constructible _led; - - -static int led_connect(struct input_handler *handler, struct input_dev *dev, - const struct input_device_id *id) -{ - _led->wait_for_registry(); - - Keyboard_led *keyboard = new (Lx_kit::env().heap()) Keyboard_led(_registry, dev); - _led->update(*keyboard); - - input_handle *handle = (input_handle *)kzalloc(sizeof(input_handle), 0); - handle->dev = input_get_device(dev); - handle->handler = handler; - - input_register_handle(handle); - - return 0; -} - - -static void led_disconnect(struct input_handle *handle) -{ - input_dev *dev = handle->dev; - - _led->wait_for_registry(); - - _registry.for_each([&] (Keyboard_led &keyboard) { - if (keyboard.match(dev)) - destroy(Lx_kit::env().heap(), &keyboard); - }); - - input_unregister_handle(handle); - input_put_device(dev); - kfree(handle); -} - - -static bool led_match(struct input_handler *handler, struct input_dev *dev) -{ - hid_device *hid = (hid_device *)input_get_drvdata(dev); - hid_report *report; - - /* search report for keyboard entries */ - list_for_each_entry(report, &hid->report_enum[0].report_list, list) { - - for (unsigned i = 0; i < report->maxfield; i++) - for (unsigned j = 0; j < report->field[i]->maxusage; j++) { - hid_usage *usage = report->field[i]->usage + j; - if ((usage->hid & HID_USAGE_PAGE) == HID_UP_KEYBOARD) { - return true; - } - } - } - - return false; -} - - -static struct input_handler led_handler; -static struct input_device_id led_ids[2]; - -static int led_init(void) -{ - led_ids[0].driver_info = 1; /* match all */ - led_ids[1] = {}; - - led_handler.name = "led"; - led_handler.connect = led_connect; - led_handler.disconnect = led_disconnect; - led_handler.id_table = led_ids; - led_handler.match = led_match; - - _led.construct(); - - return input_register_handler(&led_handler); -} - - -extern "C" { module_init(led_init); } diff --git a/repos/dde_linux/src/drivers/usb/input/input_component.cc b/repos/dde_linux/src/drivers/usb/input/input_component.cc deleted file mode 100644 index b55bce56cc..0000000000 --- a/repos/dde_linux/src/drivers/usb/input/input_component.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - * \brief Linux 2.6 Input driver for USB HID - * \author Christian Helmuth - * \author Christian Prochaska - * \author Sebastian Sumpf - * \date 2011-07-15 - */ - -/* - * Copyright (C) 2011-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include -#include - -#include -#include "platform.h" - -#undef RELEASE - -using namespace Genode; - - -/** - * Singleton instance of input-session component - */ -static Genode::Constructible _event_session; - - -/** - * Input event call-back function - */ -static void input_callback(enum input_event_type type, - unsigned code, int ax, int ay, int rx, int ry) -{ - auto submit = [&] (Input::Event const &ev) { - _event_session->with_batch([&] (Event::Session_client::Batch &batch) { - batch.submit(ev); }); - }; - - using namespace Input; - - switch (type) { - case EVENT_TYPE_PRESS: submit(Press{Keycode(code)}); break; - case EVENT_TYPE_RELEASE: submit(Release{Keycode(code)}); break; - case EVENT_TYPE_MOTION: - if (rx == 0 && ry == 0) - submit(Absolute_motion{ax, ay}); - else - submit(Relative_motion{rx, ry}); - break; - case EVENT_TYPE_WHEEL: submit(Wheel{rx, ry}); break; - case EVENT_TYPE_TOUCH: - { - Touch_id const id { (int)code }; - - if (rx == -1 && ry == -1) - submit(Touch_release{id}); - else - submit(Touch{id, (float)ax, (float)ay}); - break; - } - } -} - - -void start_input_service(void *service_ptr) -{ - Services *service = static_cast(service_ptr); - Env &env = service->env; - - _event_session.construct(env); - - genode_input_register(input_callback, service->screen_width, - service->screen_height, service->multitouch); -} diff --git a/repos/dde_linux/src/drivers/usb/input/led_state.h b/repos/dde_linux/src/drivers/usb/input/led_state.h deleted file mode 100644 index 9cd3362038..0000000000 --- a/repos/dde_linux/src/drivers/usb/input/led_state.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * \brief Configuration of keyboard mode indicators - * \author Norman Feske - * \date 2017-10-25 - */ - -/* - * Copyright (C) 2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _INPUT__LED_STATE_H_ -#define _INPUT__LED_STATE_H_ - -#include -#include -#include - -namespace Usb { struct Led_state; } - - -struct Usb::Led_state -{ - Genode::Env &_env; - - typedef Genode::String<32> Name; - - Name const _name; - - Genode::Constructible _rom; - - bool _enabled = false; - - Led_state(Genode::Env &env, Name const &name) : _env(env), _name(name) { } - - void update(Genode::Xml_node config, Genode::Signal_context_capability sigh) - { - typedef Genode::String<32> Attr; - typedef Genode::String<16> Value; - - Attr const attr(_name, "_led"); - Value const value = config.attribute_value(attr.string(), Value()); - - bool const rom_configured = (value == "rom"); - - if (rom_configured && !_rom.constructed()) { - _rom.construct(_env, _name.string()); - _rom->sigh(sigh); - } - - if (!rom_configured && _rom.constructed()) - _rom.destruct(); - - if (_rom.constructed()) - _rom->update(); - - _enabled = _rom.constructed() ? _rom->xml().attribute_value("enabled", false) - : config.attribute_value(attr.string(), false); - } - - bool enabled() const { return _enabled; } -}; - -#endif /* _INPUT__LED_STATE_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/lx_emul.cc b/repos/dde_linux/src/drivers/usb/lx_emul.cc deleted file mode 100644 index 7041890a67..0000000000 --- a/repos/dde_linux/src/drivers/usb/lx_emul.cc +++ /dev/null @@ -1,1157 +0,0 @@ -/* - * \brief Emulation of Linux kernel interfaces - * \author Norman Feske - * \author Sebastian Sumpf - * \date 2012-01-29 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -/* Genode includes */ -#include -#include -#include -#include -#include - -/* Local includes */ -#include "signal.h" -#include "lx_emul.h" - -#include -#include -#include -#include - - -#include - -namespace Genode { - class Slab_backend_alloc; - class Slab_alloc; -} - - -unsigned long jiffies; -void backtrace() { } - - -void pci_dev_put(struct pci_dev *pci_dev) -{ - Genode::destroy(&Lx_kit::env().heap(), pci_dev); -} - -/*********************** - ** Atomic operations ** - ***********************/ - -/* - * Actually not atomic, for now - */ - -unsigned int atomic_read(atomic_t *p) { return p->v; } - -void atomic_inc(atomic_t *v) { v->v++; } -void atomic_dec(atomic_t *v) { v->v--; } - -void atomic_add(int i, atomic_t *v) { v->v += i; } -void atomic_sub(int i, atomic_t *v) { v->v -= i; } - -void atomic_set(atomic_t *p, unsigned int v) { p->v = v; } - - -/************************************* - ** Memory allocation, linux/slab.h ** - *************************************/ - -void *dma_malloc(size_t size) -{ - return Lx::Malloc::dma().alloc_large(size); -} - - -void dma_free(void *ptr) -{ - Lx::Malloc::dma().free_large(ptr); -} - - -/********************* - ** linux/vmalloc.h ** - *********************/ - -void *vzalloc(unsigned long size) -{ - size_t *addr; - try { addr = (size_t *)Lx::Malloc::mem().alloc_large(size); } - catch (...) { return 0; } - - memset(addr, 0, size); - - return addr; -} - - -void vfree(void *addr) -{ - if (!addr) return; - Lx::Malloc::mem().free_large(addr); -} - - -/****************** - ** linux/kref.h ** - ******************/ - -void kref_init(struct kref *kref) -{ - lx_log(DEBUG_KREF,"%s ref: %p", __func__, kref); - kref->refcount.v = 1; -} - - -void kref_get(struct kref *kref) -{ - kref->refcount.v++; - lx_log(DEBUG_KREF, "%s ref: %p c: %d", __func__, kref, kref->refcount.v); -} - - -int kref_put(struct kref *kref, void (*release) (struct kref *kref)) -{ - lx_log(DEBUG_KREF, "%s: ref: %p c: %d", __func__, kref, kref->refcount.v); - - if (!--kref->refcount.v) { - release(kref); - return 1; - } - return 0; -} - - -/********************* - ** linux/uaccess.h ** - *********************/ - -size_t copy_to_user(void *dst, void const *src, size_t len) -{ - if (dst && src && len) - memcpy(dst, src, len); - return 0; -} - - -size_t copy_from_user(void *dst, void const *src, size_t len) -{ - if (dst && src && len) - memcpy(dst, src, len); - return 0; -} - - -bool access_ok(int access, void *addr, size_t size) { return 1; } - - -/******************** - ** linux/string.h ** - ********************/ - -void *_memcpy(void *d, const void *s, size_t n) -{ - return Genode::memcpy(d, s, n); -} - - -inline void *memset(void *s, int c, size_t n) -{ - return Genode::memset(s, c, n); -} - - -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) -{ - Genode::String_console sc(buf, size); - sc.vprintf(fmt, args); - - return sc.len(); -} - - -int snprintf(char *buf, size_t size, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - Genode::String_console sc(buf, size); - sc.vprintf(fmt, args); - va_end(args); - - return sc.len(); -} - - -int scnprintf(char *buf, size_t size, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - Genode::String_console sc(buf, size); - sc.vprintf(fmt, args); - va_end(args); - - return sc.len(); -} - -int strcmp(const char *s1, const char *s2) -{ - printk("%s:%d from %p\n", __func__, __LINE__, __builtin_return_address(0)); - return Genode::strcmp(s1, s2); -} -size_t strlen(const char *s) { return Genode::strlen(s); } - - -size_t strlcat(char *dest, const char *src, size_t count) -{ - size_t dsize = strlen(dest); - size_t len = strlen(src); - size_t res = dsize + len; - - /* This would be a bug */ - BUG_ON(dsize >= count); - - dest += dsize; - count -= dsize; - if (len >= count) - len = count-1; - memcpy(dest, src, len); - dest[len] = 0; - return res; -} - - -size_t strlcpy(char *dest, const char *src, size_t size) -{ - size_t ret = strlen(src); - - if (size) { - size_t len = (ret >= size) ? size - 1 : ret; - Genode::memcpy(dest, src, len); - dest[len] = '\0'; - } - return ret; -} - - -void *memscan(void *addr, int c, size_t size) -{ - unsigned char* p = (unsigned char *)addr; - - for (size_t s = 0; s < size; s++, p++) - if (*p == c) - break; - - return (void *)p; -} - - -/***************** - ** linux/gfp.h ** - *****************/ - -unsigned long get_zeroed_page(gfp_t gfp_mask) -{ - return (unsigned long)kzalloc(PAGE_SIZE, 0); -} - - -/****************** - ** linux/log2.h ** - ******************/ - -int ilog2(u32 n) { return Genode::log2(n); } - - -/******************** - ** linux/slab.h ** - ********************/ - - -void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags) -{ - void *ret; - ret = kmem_cache_alloc(cache, flags); - memset(ret, 0, cache->size()); - - return ret; -} - - -/********************** - ** asm-generic/io.h ** - **********************/ - -void *phys_to_virt(unsigned long address) -{ - return (void *)Lx::Malloc::dma().virt_addr(address); -} - - -/******************** - ** linux/device.h ** - ********************/ - -/** - * Simple driver management class - */ -class Driver : public Genode::List::Element -{ - private: - - struct device_driver *_drv; /* Linux driver */ - - public: - - Driver(struct device_driver *drv) : _drv(drv) - { - list()->insert(this); - } - - /** - * List of all currently registered drivers - */ - static Genode::List *list() - { - static Genode::List _list; - return &_list; - } - - /** - * Match device and drivers - */ - bool match(struct device *dev) - { - /* - * Don't try if buses don't match, since drivers often use 'container_of' - * which might cast the device to non-matching type - */ - if (_drv->bus != dev->bus) - return false; - - bool ret = _drv->bus->match ? _drv->bus->match(dev, _drv) : true; - lx_log(DEBUG_DRIVER, "MATCH: %s ret: %u match: %p %p", - _drv->name, ret, _drv->bus->match, _drv->probe); - return ret; - } - - /** - * Probe device with driver - */ - int probe(struct device *dev) - { - dev->driver = _drv; - - if (dev->bus->probe) - return dev->bus->probe(dev); - else if (_drv->probe) - return _drv->probe(dev); - - return 0; - } -}; - - -int driver_register(struct device_driver *drv) -{ - lx_log(DEBUG_DRIVER, "%s at %p", drv->name, drv); - new (Lx::Malloc::mem()) Driver(drv); - return 0; -} - - -int device_add(struct device *dev) -{ - if (dev->driver) - return 0; - - /* foreach driver match and probe device */ - for (Driver *driver = Driver::list()->first(); driver; driver = driver->next()) - if (driver->match(dev)) { - int ret = driver->probe(dev); - lx_log(DEBUG_DRIVER, "Probe return %d", ret); - - if (!ret) - return 0; - } - - return 0; -} - - -void device_del(struct device *dev) -{ - if (dev->driver && dev->driver->remove) - dev->driver->remove(dev); - - if (dev->bus && dev->bus->remove) - dev->bus->remove(dev); -} - - -int device_register(struct device *dev) -{ - return device_add(dev); -} - - -void device_unregister(struct device *dev) -{ - device_del(dev); - put_device(dev); -} - - -int device_is_registered(struct device *dev) -{ - return 1; -} - - -void device_release_driver(struct device *dev) -{ - /* is usb_unbind_interface(dev); */ - if (dev->driver->remove) - dev->driver->remove(dev); - - dev->driver = nullptr; -} - - -void put_device(struct device *dev) -{ - if (dev->ref) { - dev->ref--; - return; - } - - if (dev->release) - dev->release(dev); - else if (dev->type && dev->type->release) - dev->type->release(dev); -} - - -struct device *get_device(struct device *dev) -{ - dev->ref++; - - return dev; -} - - -void *dev_get_drvdata(const struct device *dev) -{ - return dev->driver_data; -} - - -int dev_set_drvdata(struct device *dev, void *data) -{ - dev->driver_data = data; return 0; -} - - -const char *dev_name(const struct device *dev) { return dev->name; } - - -/******************************* - ** asm-generic/bitops/find.h ** - *******************************/ - -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset) -{ - unsigned long i = offset / BITS_PER_LONG; - offset -= (i * BITS_PER_LONG); - - for (; offset < size; offset++) - if (addr[i] & (1UL << offset)) - return offset + (i * BITS_PER_LONG); - - return size; -} - - -long find_next_zero_bit_le(const void *addr, - unsigned long size, unsigned long offset) -{ - static unsigned cnt = 0; - unsigned long max_size = sizeof(long) * 8; - if (offset >= max_size) { - Genode::warning("Offset greater max size"); - return offset + size; - } - - for (; offset < max_size; offset++) - if (!(*(unsigned long*)addr & (1L << offset))) - return offset; - - return offset + size; -} - - -void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) -{ - return kzalloc(size, gfp); -} - - -void *dev_get_platdata(const struct device *dev) -{ - return (void *)dev->platform_data; -} - - -/******************************* - ** linux/byteorder/generic.h ** - *******************************/ - -u16 get_unaligned_le16(const void *p) -{ - const struct __una_u16 *ptr = (const struct __una_u16 *)p; - return ptr->x; -} - - -void put_unaligned_le16(u16 val, void *p) -{ - struct __una_u16 *ptr = (struct __una_u16 *)p; - ptr->x = val; -} - -u32 get_unaligned_le32(const void *p) -{ - const struct __una_u32 *ptr = (const struct __una_u32 *)p; - return ptr->x; -} - - -void put_unaligned_le32(u32 val, void *p) -{ - struct __una_u32 *ptr = (struct __una_u32 *)p; - ptr->x = val; -} - - -u64 get_unaligned_le64(const void *p) -{ - const struct __una_u64 *ptr = (const struct __una_u64 *)p; - return ptr->x; -} - - -void put_unaligned_le64(u64 val, void *p) -{ - struct __una_u64 *ptr = (struct __una_u64 *)p; - ptr->x = val; -} - - -/********************************** - ** linux/bitops.h, asm/bitops.h ** - **********************************/ - -int fls(int x) -{ - if (!x) - return 0; - - for (int i = 31; i >= 0; i--) - if (x & (1 << i)) - return i + 1; - - return 0; -} - - -/******************* - ** linux/delay.h ** - *******************/ - -#include - - -/********* - ** DMA ** - *********/ - -struct dma_pool -{ - size_t size; - int align; -}; - -struct dma_pool *dma_pool_create(const char *name, struct device *d, size_t size, - size_t align, size_t alloc) -{ - lx_log(DEBUG_DMA, "size: %zx align:%zx %p", size, align, __builtin_return_address((0))); - - if (align & (align - 1)) - return 0; - - dma_pool *pool = new(Lx::Malloc::mem()) dma_pool; - pool->align = Genode::log2((int)align); - pool->size = size; - return pool; -} - - -void dma_pool_destroy(struct dma_pool *d) -{ - lx_log(DEBUG_DMA, "close"); - destroy(Lx::Malloc::mem(), d); -} - - -void *dma_pool_alloc(struct dma_pool *d, gfp_t f, dma_addr_t *dma) -{ - void *addr; - addr = dma_alloc_coherent(0, d->size, dma, 0); - - lx_log(DEBUG_DMA, "addr: %p size %zx align %x phys: %lx pool %p", - addr, d->size, d->align, *dma, d); - return addr; -} - - -void dma_pool_free(struct dma_pool *d, void *vaddr, dma_addr_t a) -{ - lx_log(DEBUG_DMA, "free: addr %p, size: %zx", vaddr, d->size); - Lx::Malloc::dma().free(vaddr); -} - - -void *dma_alloc_coherent(struct device *, size_t size, dma_addr_t *dma, gfp_t) -{ - void *addr = Lx::Malloc::dma().alloc(size, PAGE_SHIFT, dma); - - if (!addr) - return 0; - - lx_log(DEBUG_DMA, "DMA pool alloc addr: %p size %zx align: %d, phys: %lx", - addr, size, PAGE_SHIFT, *dma); - return addr; -} - - -void dma_free_coherent(struct device *, size_t size, void *vaddr, dma_addr_t) -{ - lx_log(DEBUG_DMA, "free: addr %p, size: %zx", vaddr, size); - Lx::Malloc::dma().free(vaddr); -} - - -/************************* - ** linux/dma-mapping.h ** - *************************/ - -dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, - size_t size, - enum dma_data_direction dir, - struct dma_attrs *attrs) -{ - dma_addr_t phys = (dma_addr_t)Lx::Malloc::dma().phys_addr(ptr); - - if (phys == ~0UL) - Genode::error("translation virt->phys ", ptr, "->", Genode::Hex(phys), " failed, return ip ", - __builtin_return_address(0)); - - lx_log(DEBUG_DMA, "virt: %p phys: %lx", ptr, phys); - return phys; -} - - -dma_addr_t dma_map_page(struct device *dev, struct page *page, - size_t offset, size_t size, - enum dma_data_direction dir) -{ - lx_log(DEBUG_DMA, "virt: %p phys: %lx offs: %zx", page->virt, page->phys, offset); - return page->phys + offset; -} - - -int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction dir, - struct dma_attrs *attrs) { return nents; } - - -/********************* - ** linux/kthread.h ** - *********************/ - -struct task_struct *kthread_run(int (*fn)(void *), void *arg, const char *n, ...) -{ - /* - * This is just called for delayed device scanning (see - * 'drivers/usb/storage/usb.c') - */ - lx_log(DEBUG_THREAD, "Run %s", n); - - new (Lx::Malloc::mem()) Lx::Task((void (*)(void *))fn, arg, n, - Lx::Task::PRIORITY_2, - Lx::scheduler()); - return 0; -} - - -/************************* - ** linux/scatterlist.h ** - *************************/ - -struct scatterlist *sg_next(struct scatterlist *sg) -{ - if (sg->last) - return 0; - - return sg++; -} - - -struct page *sg_page(struct scatterlist *sg) -{ - if (!sg) - return 0; - - return (page *)sg->page_link; -} - - -void *sg_virt(struct scatterlist *sg) -{ - if (!sg || !sg->page_link) - return 0; - - struct page *page = (struct page *)sg->page_link; - return (void *)((unsigned long)page->virt + sg->offset); -} - - -/******************** - ** linux/ioport.h ** - ********************/ - -struct resource * devm_request_mem_region(struct device *dev, resource_size_t start, - resource_size_t n, const char *name) -{ - struct resource *r = (struct resource *)kzalloc(sizeof(struct resource), GFP_KERNEL); - r->start = start; - r->end = start + n - 1; - r->name = name; - - return r; -} - - -/***************** - ** linux/smp.h ** - *****************/ - -int smp_call_function_single(int cpu, smp_call_func_t func, void *info, - int wait) { func(info); return 0; } - - -/**************** - ** Networking ** - ****************/ - - -/************************* - ** linux/etherdevice.h ** - *************************/ - -struct net_device *alloc_etherdev(int sizeof_priv) -{ - net_device *dev = new (Lx::Malloc::mem()) net_device(); - - dev->mtu = 1500; - dev->hard_header_len = 0; - dev->priv = kzalloc(sizeof_priv, 0); - dev->dev_addr = dev->_dev_addr; - memset(dev->_dev_addr, 0, sizeof(dev->_dev_addr)); - - return dev; -} - - -int is_valid_ether_addr(const u8 *addr) -{ - /* is multicast */ - if ((addr[0] & 0x1)) - return 0; - - /* zero */ - if (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) - return 0; - - return 1; -} - - -/***************** - ** linux/mii.h ** - *****************/ - -/** - * Restart NWay (autonegotiation) for this interface - */ -int mii_nway_restart (struct mii_if_info *mii) -{ - int bmcr; - int r = -EINVAL; - enum { - BMCR_ANENABLE = 0x1000, /* enable auto negotiation */ - BMCR_ANRESTART = 0x200, /* auto negotation restart */ - }; - - /* if autoneg is off, it's an error */ - bmcr = mii->mdio_read(mii->dev, mii->phy_id, MII_BMCR); - - if (bmcr & BMCR_ANENABLE) { - printk("Reanable\n"); - bmcr |= BMCR_ANRESTART; - mii->mdio_write(mii->dev, mii->phy_id, MII_BMCR, bmcr); - r = 0; - } - - return r; -} - - -int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) -{ - ecmd->duplex = DUPLEX_FULL; - return 0; -} - - -u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv) -{ - u8 cap = 0; - - if (lcladv & rmtadv & ADVERTISE_PAUSE_CAP) { - cap = FLOW_CTRL_TX | FLOW_CTRL_RX; - } else if (lcladv & rmtadv & ADVERTISE_PAUSE_ASYM) { - if (lcladv & ADVERTISE_PAUSE_CAP) - cap = FLOW_CTRL_RX; - else if (rmtadv & ADVERTISE_PAUSE_CAP) - cap = FLOW_CTRL_TX; - } - - return cap; -} - -int mii_link_ok (struct mii_if_info *mii) -{ - /* first, a dummy read, needed to latch some MII phys */ - mii->mdio_read(mii->dev, mii->phy_id, MII_BMSR); - if (mii->mdio_read(mii->dev, mii->phy_id, MII_BMSR) & BMSR_LSTATUS) - return 1; - return 0; -} - - -unsigned int mii_check_media (struct mii_if_info *mii, - unsigned int ok_to_print, - unsigned int init_media) -{ - if (mii_link_ok(mii)) - netif_carrier_on(mii->dev); - else - netif_carrier_off(mii->dev); - return 0; -} - - -/****************** - ** linux/log2.h ** - ******************/ - - -int rounddown_pow_of_two(u32 n) -{ - return 1U << Genode::log2(n); -} - - -/***************** - ** linux/nls.h ** - *****************/ - -int utf16s_to_utf8s(const wchar_t *pwcs, int len, - enum utf16_endian endian, u8 *s, int maxlen) -{ - /* - * We do not convert to char, we simply copy the UTF16 plane 0 values - */ - u16 *out = (u16 *)s; - u16 *in = (u16 *)pwcs; - int length = min(len, maxlen / 2); - for (int i = 0; i < length; i++) - out[i] = in[i]; - - return 2 * length; -} - -/********************** - ** linux/notifier.h ** - **********************/ - -int raw_notifier_chain_register(struct raw_notifier_head *nh, - struct notifier_block *n) -{ - struct notifier_block *nl = nh->head; - struct notifier_block *pr = 0; - while (nl) { - if (n->priority > nl->priority) - break; - pr = nl; - nl = nl->next; - } - - n->next = nl; - if (pr) - pr->next = n; - else - nh->head = n; - - return 0; -} - - -int raw_notifier_call_chain(struct raw_notifier_head *nh, - unsigned long val, void *v) -{ - int ret = NOTIFY_DONE; - struct notifier_block *nb = nh->head; - - while (nb) { - - ret = nb->notifier_call(nb, val, v); - if ((ret & NOTIFY_STOP_MASK) == NOTIFY_STOP_MASK) - break; - - nb = nb->next; - } - - return ret; -} - - -int blocking_notifier_chain_register(struct blocking_notifier_head *nh, - struct notifier_block *n) -{ - return raw_notifier_chain_register((struct raw_notifier_head *)nh, n); -} - - -int blocking_notifier_call_chain(struct blocking_notifier_head *nh, - unsigned long val, void *v) -{ - return raw_notifier_call_chain((struct raw_notifier_head *)nh, val, v); -} - - -/******************* - ** linux/timer.h ** - *******************/ - -#include -#include - -signed long schedule_timeout_uninterruptible(signed long timeout) -{ - lx_log(DEBUG_COMPLETION, "%ld\n", timeout); - schedule_timeout(timeout); - return 0; -} - - -/************************ - ** linux/completion.h ** - ************************/ - -#include - - -static void _completion_timeout(unsigned long t) -{ - Lx::Task *task = (Lx::Task *)t; - task->unblock(); -} - - -long __wait_completion(struct completion *work, unsigned long timeout) -{ - timer_list t; - unsigned long j = timeout ? jiffies + timeout : 0; - - if (timeout) { - setup_timer(&t, _completion_timeout, - (unsigned long)Lx::scheduler().current()); - mod_timer(&t, j); - } - - while (!work->done) { - - if (j && j <= jiffies) - return 0; - - Lx::Task *task = Lx::scheduler().current(); - work->task = (void *)task; - task->block_and_schedule(); - } - - if (timeout) - del_timer(&t); - - work->done = 0; - - return j ? j - jiffies : 1; -} - - -/*********************** - ** linux/workqueue.h ** - ***********************/ - -#include - - -void tasklet_init(struct tasklet_struct *t, void (*f)(unsigned long), unsigned long d) -{ - t->func = f; - t->data = d; -} - - -void tasklet_schedule(struct tasklet_struct *tasklet) -{ - Lx::Work *lx_work = (Lx::Work *)tasklet_wq->task; - lx_work->schedule_tasklet(tasklet); - lx_work->unblock(); -} - - -void tasklet_hi_schedule(struct tasklet_struct *tasklet) -{ - tasklet_schedule(tasklet); -} - - -struct workqueue_struct *create_singlethread_workqueue(char const *name) -{ - workqueue_struct *wq = (workqueue_struct *)kzalloc(sizeof(workqueue_struct), 0); - Lx::Work *work = Lx::Work::alloc_work_queue(&Lx::Malloc::mem(), name); - wq->task = (void *)work; - - return wq; -} - - -struct workqueue_struct *alloc_workqueue(const char *fmt, unsigned int flags, - int max_active, ...) -{ - return create_singlethread_workqueue(fmt); -} - - -/****************** - ** linux/wait.h ** - ******************/ - -#include - -/******************* - ** lib/hexdump.c ** - *******************/ - -#include - -/** - * hex_to_bin - convert a hex digit to its real value - * @ch: ascii character represents hex digit - * - * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad - * input. - */ -int hex_to_bin(char ch) -{ - if ((ch >= '0') && (ch <= '9')) - return ch - '0'; - ch = tolower(ch); - if ((ch >= 'a') && (ch <= 'f')) - return ch - 'a' + 10; - return -1; -} - -/** - * hex2bin - convert an ascii hexadecimal string to its binary representation - * @dst: binary result - * @src: ascii hexadecimal string - * @count: result length - * - * Return 0 on success, -1 in case of bad input. - */ -int hex2bin(u8 *dst, const char *src, size_t count) -{ - while (count--) { - int hi = hex_to_bin(*src++); - int lo = hex_to_bin(*src++); - - if ((hi < 0) || (lo < 0)) - return -1; - - *dst++ = (hi << 4) | lo; - } - return 0; -} - - -/******************* - ** linux/timer.h ** - *******************/ - -extern "C" void init_timer(struct timer_list *) { } - -struct callback_timer { - void (*function)(unsigned long); - unsigned long data; -}; - -/* - * For compatibility with 4.4.3 drivers, the argument of this callback function - * is the 'data' member of the 'timer_list' object, which normally points to - * the 'timer_list' object itself when initialized with 'timer_setup()', but - * here it was overridden in 'setup_timer()' to point to the 'callback_timer' - * object instead. - */ -static void timer_callback(struct timer_list *t) -{ - struct callback_timer * tc = (struct callback_timer *)t; - tc->function(tc->data); -} - -extern "C" void setup_timer(struct timer_list *timer, void (*function)(unsigned long), - unsigned long data) -{ - callback_timer * tc = new (Lx::Malloc::mem()) callback_timer; - tc->function = function; - tc->data = data; - - timer_setup(timer, timer_callback, 0u); - timer->data = (unsigned long)tc; -} diff --git a/repos/dde_linux/src/drivers/usb/main.cc b/repos/dde_linux/src/drivers/usb/main.cc deleted file mode 100644 index 31077e50f0..0000000000 --- a/repos/dde_linux/src/drivers/usb/main.cc +++ /dev/null @@ -1,221 +0,0 @@ -/* - * \brief Startup USB driver library - * \author Sebastian Sumpf - * \date 2013-02-20 - */ - -/* - * Copyright (C) 2013-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include -#include -#include - -/* Local */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -using namespace Genode; - -extern "C" int subsys_usb_init(); -extern "C" void subsys_input_init(); -extern "C" void module_evdev_init(); -extern "C" void module_hid_init(); -extern "C" void module_hid_init_core(); -extern "C" void module_hid_generic_init(); -extern "C" void module_usb_storage_driver_init(); -extern "C" void module_wacom_driver_init(); -extern "C" void module_ch_driver_init(); -extern "C" void module_ms_driver_init(); -extern "C" void module_mt_driver_init(); -extern "C" void module_raw_driver_init(); -extern "C" void module_led_init(); - -struct workqueue_struct *system_power_efficient_wq; -struct workqueue_struct *system_wq; -struct workqueue_struct *tasklet_wq; - -void breakpoint() { Genode::log("BREAK"); } - - -static void run_linux(void *s) -{ - Services *services = (Services *)s; - - system_power_efficient_wq = alloc_workqueue("system_power_efficient_wq", 0, 0); - system_wq = alloc_workqueue("system_wq", 0, 0); - tasklet_wq = alloc_workqueue("tasklet_wq", 0, 0); - - /* - * The RAW driver is initialized first to make sure that it doesn't miss - * notifications about added devices. - */ - if (services->raw) - /* low level interface */ - module_raw_driver_init(); - - /* USB */ - subsys_usb_init(); - - /* input + HID */ - if (services->hid) { - subsys_input_init(); - module_evdev_init(); - module_led_init(); - - /* HID */ - module_hid_init_core(); - module_hid_init(); - module_hid_generic_init(); - module_ch_driver_init(); - module_ms_driver_init(); - module_mt_driver_init(); - module_wacom_driver_init(); - } - - /* storage */ - if (services->stor) - module_usb_storage_driver_init(); - - /* host controller */ - platform_hcd_init(Lx_kit::env().env(), services); - - while (true) - Lx::scheduler().current()->block_and_schedule(); -} - - -void start_usb_driver(Genode::Env &env) -{ - /* initialize USB env */ - Lx_kit::construct_env(env); - - LX_MUTEX_INIT(hid_open_mut); - LX_MUTEX_INIT(host_cmd_pool_mutex); - LX_MUTEX_INIT(input_mutex); - LX_MUTEX_INIT(usb_bus_list_lock); - LX_MUTEX_INIT(usb_port_peer_mutex); - LX_MUTEX_INIT(usbfs_mutex); - LX_MUTEX_INIT(wacom_udev_list_lock); - - /* sets up backend alloc needed by malloc */ - backend_alloc_init(env, env.ram(), Lx_kit::env().heap()); - - Lx::malloc_init(env, Lx_kit::env().heap()); - - static Services services(env); - - if (services.hid) - start_input_service(&services); - - Storage::init(env); - Nic::init(env); - - if (services.raw) - Raw::init(env, services.raw_report_device_list); - - Lx::Scheduler &sched = Lx::scheduler(&env); - Lx::Timer &timer = Lx::timer(&env, &env.ep(), &Lx_kit::env().heap(), &jiffies); - - Lx::Irq::irq(&env.ep(), &Lx_kit::env().heap()); - Lx::Work::work_queue(&Lx_kit::env().heap()); - - static Lx::Task linux(run_linux, &services, "linux", Lx::Task::PRIORITY_0, - Lx::scheduler()); - - Lx::scheduler().schedule(); -} - - -namespace Usb_driver { - - using namespace Genode; - - struct Driver_starter { virtual void start_driver() = 0; }; - struct Main; -} - - -struct Usb_driver::Main : Driver_starter -{ - Env &_env; - - /* - * Defer the startup of the USB driver until the first configuration - * becomes available. This is needed in scenarios where the configuration - * is dynamically generated and supplied to the USB driver via the - * report-ROM service. - */ - struct Initial_config_handler - { - Driver_starter &_driver_starter; - - Attached_rom_dataspace _config; - - Signal_handler _config_handler; - - void _handle_config() - { - _config.update(); - - if (_config.xml().type() == "config") - _driver_starter.start_driver(); - } - - Initial_config_handler(Env &env, Driver_starter &driver_starter) - : - _driver_starter(driver_starter), - _config(env, "config"), - _config_handler(env.ep(), *this, &Initial_config_handler::_handle_config) - { - _config.sigh(_config_handler); - _handle_config(); - } - }; - - void _handle_start() - { - if (_initial_config_handler.constructed()) { - _initial_config_handler.destruct(); - start_usb_driver(_env); - } - } - - Signal_handler
_start_handler { - _env.ep(), *this, &Main::_handle_start }; - - Reconstructible _initial_config_handler { _env, *this }; - - /* - * Called from 'Initial_config_handler' - */ - void start_driver() override - { - Signal_transmitter(_start_handler).submit(); - } - - Main(Env &env) : _env(env) { } -}; - - -void Component::construct(Genode::Env &env) -{ - /* XXX execute constructors of global statics */ - env.exec_static_constructors(); - - static Usb_driver::Main main(env); -} diff --git a/repos/dde_linux/src/drivers/usb/nic/nic.cc b/repos/dde_linux/src/drivers/usb/nic/nic.cc deleted file mode 100644 index 8900732dc8..0000000000 --- a/repos/dde_linux/src/drivers/usb/nic/nic.cc +++ /dev/null @@ -1,763 +0,0 @@ -/* - * \brief Glue code for Linux network drivers - * \author Sebastian Sumpf - * \date 2012-07-05 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -/* Genode includes */ -#include -#include -#include -#include - -/* Linux emulation environment includes */ -#include -#include - -/* NIC driver includes */ -#include - -/* local includes */ -#include -#include "signal.h" - - -static Signal_helper *_signal = 0; - -enum { - HEAD_ROOM = 8, /* head room in skb in bytes */ - MAC_LEN = 17, /* 12 number and 6 colons */ -}; - - -/** - * Internal alloc function - */ -struct sk_buff *_alloc_skb(unsigned int size, bool tx = true); - - -/** - * Skb-bitmap allocator - */ -class Skb -{ - private: - - unsigned const _entries; - - sk_buff *_buf; - unsigned *_free; - unsigned _idx; - - enum { ENTRY_ELEMENT_SIZE = sizeof(unsigned) * 8 }; - - public: - - Skb(unsigned const entries, unsigned const buffer_size) - : - _entries(entries), _idx(0) - { - unsigned const size = _entries / sizeof(unsigned); - - _buf = (sk_buff *)kmalloc(sizeof(sk_buff) * _entries, GFP_KERNEL); - _free = (unsigned *)kmalloc(sizeof(unsigned) * size, GFP_KERNEL); - - Genode::memset(_free, 0xff, size * sizeof(unsigned)); - - for (unsigned i = 0; i < _entries; i++) - _buf[i].start = (unsigned char *)kmalloc(buffer_size + NET_IP_ALIGN, GFP_NOIO); - } - - sk_buff *alloc() - { - unsigned const IDX = _entries / ENTRY_ELEMENT_SIZE; - - for (unsigned i = 0; i < IDX; i++) { - if (_free[_idx] != 0) { - unsigned msb = Genode::log2(_free[_idx]); - _free[_idx] ^= (1 << msb); - - sk_buff *r = &_buf[(_idx * ENTRY_ELEMENT_SIZE) + msb]; - r->data = r->start; - r->head = r->data; - r->phys = 0; - r->cloned = 0; - r->clone = 0; - r->len = 0; - return r; - } - _idx = (_idx + 1) % IDX; - } - - - return 0; - } - - void free(sk_buff *buf) - { - unsigned entry = buf - &_buf[0]; - if (&_buf[0] > buf || entry > _entries) - return; - - _idx = entry / ENTRY_ELEMENT_SIZE; - _free[_idx] |= (1 << (entry % ENTRY_ELEMENT_SIZE)); - } -}; - - -/* send/receive skb allocators */ -static Skb *skb_tx(unsigned const elements = 0, unsigned const buffer_size = 0) -{ - static Skb _skb(elements, buffer_size); - return &_skb; -} - - -static Skb *skb_rx(unsigned const elements = 0, unsigned const buffer_size = 0) -{ - static Skb _skb(elements, buffer_size); - return &_skb; -} - - -/** - * Prototype of fixup function - */ -extern "C" { -typedef struct sk_buff* (*fixup_t)(struct usbnet *, struct sk_buff *, gfp_t); -} - - -/** - * Net_device to session glue code - */ -class Nic_device : public Usb_nic::Device -{ - public: - - struct net_device *_ndev; /* Linux-net device */ - fixup_t _tx_fixup; - bool const _burst; - bool _has_link { false }; - - public: - - Nic_device(struct net_device *ndev) - : - _ndev(ndev), - /* XXX should be configurable instead of guessing burst mode */ - _burst(((usbnet *)netdev_priv(ndev))->rx_urb_size > 2048) - { - struct usbnet *dev = (usbnet *)netdev_priv(_ndev); - - /* initialize skb allocators */ - unsigned urb_cnt = dev->rx_urb_size <= 2048 ? 128 : 64; - skb_rx(urb_cnt, dev->rx_urb_size); - skb_tx(urb_cnt, dev->rx_urb_size); - - if (!burst()) return; - - /* - * Retrieve 'tx_fixup' function from driver and set it to zero, - * so it cannot be called by the actual driver. Required for - * burst mode. - */ - _tx_fixup = dev->driver_info->tx_fixup; - dev->driver_info->tx_fixup = 0; - } - - /** - * Add device - */ - static Nic_device *add(struct net_device *ndev) { - return new (Lx::Malloc::mem()) Nic_device(ndev); } - - /** - * Report link state - */ - void link_state(bool link) - { - /* only report changes of the link state */ - if (link == _has_link) - return; - - _has_link = link; - - if (_session) - _session->link_state_changed(); - } - - - - /********************** - ** Device interface ** - **********************/ - - bool link_state() override { return _has_link; } - - /** - * Submit packet to driver - */ - bool tx(Genode::addr_t virt, Genode::size_t size) - { - sk_buff *skb; - - if (!(skb = _alloc_skb(size + HEAD_ROOM))) - return false; - - skb->len = size; - skb->data += HEAD_ROOM; - Genode::memcpy(skb->data, (void *)virt, skb->len); - - tx_skb(skb); - return true; - } - - /** - * Alloc an SKB - */ - sk_buff *alloc_skb() - { - struct usbnet *dev = (usbnet *)netdev_priv(_ndev); - sk_buff *skb; - - if (!(skb = _alloc_skb(dev->rx_urb_size))) - return 0; - - skb->len = 0; - return skb; - } - - /** - * Submit SKB to the driver - */ - void tx_skb(sk_buff *skb) - { - struct usbnet *dev = (usbnet *)netdev_priv(_ndev); - unsigned long dropped = dev->net->stats.tx_dropped; - _ndev->netdev_ops->ndo_start_xmit(skb, _ndev); - - if (dropped < dev->net->stats.tx_dropped) - Genode::warning("Dropped SKB"); - } - - /** - * Call tx_fixup function of driver - */ - void tx_fixup(struct sk_buff *skb) - { - struct usbnet *dev = (usbnet *)netdev_priv(_ndev); - if(!_tx_fixup || !_tx_fixup(dev, skb, 0)) - Genode::error("Tx fixup error"); - } - - - /** - * Fill an SKB with 'data' if 'size', return false if SKB is greater than - * 'end' - */ - bool skb_fill(struct sk_buff *skb, unsigned char *data, Genode::size_t size, unsigned char *end) - { - Genode::addr_t align = ((Genode::addr_t)(data + 3) & ~3); - skb->truesize = skb->data == 0 ? 0 : (unsigned char*)align - data; - data = skb->data == 0 ? data : (unsigned char*)align; - - skb->start = data; - data += HEAD_ROOM; - skb->len = size; - skb->data = data; - skb->end = skb->tail = data + size; - skb->truesize += (skb->end - skb->start); - - - return skb->end >= end ? false : true; - } - - /** - * Submit packet for session - */ - inline void rx(sk_buff *skb) { _session->rx((Genode::addr_t)skb->data, skb->len); } - - /** - * Return mac address - */ - Nic::Mac_address mac_address() - { - Nic::Mac_address m; - Genode::memcpy(&m, _ndev->_dev_addr, ETH_ALEN); - return m; - } - - bool burst() { return _burst; } -}; - - -/* XXX support multiple devices */ -static Nic_device *_nic = 0; - - -void Nic::init(Genode::Env &env) { - _signal = new (Lx::Malloc::mem()) Signal_helper(env); } - - -/*********************** - ** linux/netdevice.h ** - ***********************/ - -int register_netdev(struct net_device *ndev) -{ - using namespace Genode; - static bool registered = false; - int err = -ENODEV; - - Nic_device *nic = Nic_device::add(ndev); - if (nic == nullptr) { - - class Invalid_nic_device { }; - throw Invalid_nic_device { }; - } - - /* XXX: move to 'main' */ - if (!registered) { - - registered = true; - - Nic_driver_mode const mode { - read_nic_driver_mode(Lx_kit::env().config_rom().xml()) }; - - switch (mode) { - case Genode::Nic_driver_mode::NIC_SERVER: - - static ::Root root(_signal->env(), Lx::Malloc::mem(), *nic); - ndev->state |= 1 << __LINK_STATE_START; - - if ((err = ndev->netdev_ops->ndo_open(ndev))) - return err; - - if (ndev->netdev_ops->ndo_set_rx_mode) - ndev->netdev_ops->ndo_set_rx_mode(ndev); - - _nic = nic; - _signal->parent().announce(_signal->ep().rpc_ep().manage(&root)); - log("Acting as Nic server"); - break; - - case Genode::Nic_driver_mode::UPLINK_CLIENT: - - ndev->state |= 1 << __LINK_STATE_START; - if ((err = ndev->netdev_ops->ndo_open(ndev))) - return err; - - _nic = nic; - static Uplink_client uplink_client { - _signal->env(), Lx::Malloc::mem(), *nic }; - - log("Acting as Uplink client"); - break; - } - } - - return err; -} - - -int netif_running(const struct net_device *dev) -{ - return dev->state & (1 << __LINK_STATE_START); -} - - -int netif_device_present(struct net_device *dev) { return 1; } - - -int netif_carrier_ok(const struct net_device *dev) -{ - return !(dev->state & (1 << __LINK_STATE_NOCARRIER)); -} - - -void netif_carrier_on(struct net_device *dev) -{ - dev->state &= ~(1 << __LINK_STATE_NOCARRIER); - if (_nic) - _nic->link_state(true); -} - - -void netif_carrier_off(struct net_device *dev) -{ - dev->state |= 1 << __LINK_STATE_NOCARRIER; - if (_nic) - _nic->link_state(false); -} - -#ifdef GENODE_NET_STAT - #include - static Timer::Connection _timer; - static Nic::Measurement _stat(_timer); -#endif - -int netif_rx(struct sk_buff *skb) -{ - if (_nic && _nic->session()) { - _nic->rx(skb); - } -#ifdef GENODE_NET_STAT - else if (_nic) { - try { - _stat.data(new (skb->data) Net::Ethernet_frame(skb->len), skb->len); - } catch(Net::Ethernet_frame::No_ethernet_frame) { - Genode::warning("No ether frame"); - } - } -#endif - - dev_kfree_skb(skb); - return NET_RX_SUCCESS; -} - - -/******************** - ** linux/skbuff.h ** - ********************/ - -struct sk_buff *_alloc_skb(unsigned int size, bool tx) -{ - sk_buff *skb = tx ? skb_tx()->alloc() : skb_rx()->alloc(); - - if (!skb) - return 0; - - size = (size + 3) & ~(0x3); - - skb->end = skb->start + size; - skb->tail = skb->start; - skb->truesize = size; - - return skb; -} - - -struct sk_buff *alloc_skb(unsigned int size, gfp_t priority) -{ - /* - * Note: This is only called for RX skb's by the driver - */ - struct sk_buff *skb = _alloc_skb(size, false); - return skb; -} - -struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length) -{ - struct sk_buff *s = _alloc_skb(length + NET_IP_ALIGN, false); - if (s && dev->net_ip_align) { - s->data += NET_IP_ALIGN; - s->tail += NET_IP_ALIGN; - } - return s; -} - - -void dev_kfree_skb(struct sk_buff *skb) -{ - lx_log(DEBUG_SKB, "free skb: %p start: %p cloned: %d", - skb, skb->start, skb->cloned); - - if (skb->cloned) { - skb->start = skb->clone; - skb->cloned = false; - skb_rx()->free(skb); - return; - } - - skb_tx()->free(skb); - skb_rx()->free(skb); -} - - -void dev_kfree_skb_any(struct sk_buff *skb) { dev_kfree_skb(skb); } - -void kfree_skb(struct sk_buff *skb) { dev_kfree_skb(skb); } - - -/** - * Reserve 'len' - */ -void skb_reserve(struct sk_buff *skb, int len) -{ - if ((skb->data + len) > skb->end) { - Genode::error("Error resevring SKB data: skb: ", skb, " data: ", skb->data, - " end: ", skb->end, "len: ", skb->len); - return; - } - skb->data += len; - lx_log(DEBUG_SKB, "skb: %p slen: %u len: %d", skb, skb->len, len); -} - - -/** - * Prepend 'len' - */ -unsigned char *skb_push(struct sk_buff *skb, unsigned int len) -{ - if((skb->data - len) < skb->start) { - Genode::error("Error SKB head room too small: ", skb, " data: ", skb->data, - " start: ", skb->start, " len: ", len); - return 0; - } - - skb->len += len; - skb->data -= len; - - lx_log(DEBUG_SKB, "skb: %p slen: %u len: %u", skb, skb->len, len); - return skb->data; -} - - -/** - * Append 'len' - */ -unsigned char *skb_put(struct sk_buff *skb, unsigned int len) -{ - if ((skb->data + len > skb->end)) { - Genode::error("Error increasing SKB length: skb: ", skb, " data: ", skb->data, - " end: ", skb->end, " len: ", len); - return 0; - } - - unsigned char *old = skb_tail_pointer(skb); - skb->len += len; - skb->tail += len; - lx_log(DEBUG_SKB, "skb: %p slen: %u len: %u", skb, skb->len, len); - return old; -} - - -/** - * Return current head room - */ -unsigned int skb_headroom(const struct sk_buff *skb) -{ - return skb->data - skb->start; -} - - -int skb_tailroom(const struct sk_buff *skb) -{ - return skb->end - skb->tail; -} - - - -/** - * Take 'len' from front - */ -unsigned char *skb_pull(struct sk_buff *skb, unsigned int len) -{ - if (len > skb->len) { - Genode::error("Error try to pull too much: skb: ", skb, " len: ", skb->len, - " pull len: ", len); - return 0; - } - skb->len -= len; - lx_log(DEBUG_SKB, "skb: %p slen: %u len: %u", skb, skb->len, len); - return skb->data += len; -} - - -/** - * Set 'len' and 'tail' - */ -void skb_trim(struct sk_buff *skb, unsigned int len) -{ - if (skb->len < len) { - Genode::error("Error trimming to ", len, " bytes skb: ", skb, " data: ", - skb->data, " start: ", skb->start, " len ", skb->len); - return; - } - - skb->len = len; - skb_set_tail_pointer(skb, len); - - lx_log(DEBUG_SKB, "skb: %p slen: %u len: %u", skb, skb->len, len); -} - - -/** - * Clone skb - */ -struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask) -{ - sk_buff *c; - - if (!(c = alloc_skb(0,0))) - return 0; - - unsigned char *start = c->start; - *c = *skb; - - /* save old start pointer */ - c->cloned = 1; - c->clone = start; - return c; -} - - -int skb_header_cloned(const struct sk_buff *skb) -{ - return skb->cloned; -} - - -void skb_set_tail_pointer(struct sk_buff *skb, const int offset) -{ - skb->tail = skb->data + offset; -} - - -unsigned char *skb_tail_pointer(const struct sk_buff *skb) -{ - return skb->tail; -} - - -/** - * Dummy for shared info - */ -struct skb_shared_info *skb_shinfo(struct sk_buff const * /* skb */) -{ - static skb_shared_info _s = { 0 }; - return &_s; -} - - -/** - * Init list head - */ -void skb_queue_head_init(struct sk_buff_head *list) -{ - static int count_x = 0; - list->prev = list->next = (sk_buff *)list; - list->qlen = 0; -} - -/** - * Add to tail of queue - */ -void __skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk) -{ - newsk->next = (sk_buff *)list; - newsk->prev = list->prev; - list->prev->next = newsk; - list->prev = newsk; - list->qlen++; -} - - -void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk) { - __skb_queue_tail(list, newsk); } - - -/** - * Remove skb from queue - */ -void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) -{ - if (!list->qlen) - return; - - skb->prev->next = skb->next; - skb->next->prev = skb->prev; - skb->next = skb->prev = 0; - list->qlen--; -} - - -/** - * Remove from head of queue - */ -struct sk_buff *skb_dequeue(struct sk_buff_head *list) -{ - if (list->qlen == 0) - return 0; - - sk_buff *skb = list->next; - __skb_unlink(skb, list); - - return skb; -} - - -/********************** - ** linux/inerrupt.h ** - **********************/ - -static void snprint_mac(char *buf, u8 *mac) -{ - for (int i = 0; i < ETH_ALEN; i++) - { - Genode::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]); - if ((i * 3) < MAC_LEN) - buf[(i * 3) + 2] = ':'; - } - - buf[MAC_LEN] = 0; -} - - -/************************* - ** linux/etherdevice.h ** - *************************/ - -void eth_hw_addr_random(struct net_device *dev) -{ - random_ether_addr(dev->_dev_addr); -} - - -void eth_random_addr(u8 *addr) -{ - random_ether_addr(addr); -} - - -void random_ether_addr(u8 *addr) -{ - using namespace Genode; - char str[MAC_LEN + 1]; - u8 fallback[] = { 0x2e, 0x60, 0x90, 0x0c, 0x4e, 0x01 }; - Nic::Mac_address mac; - - Xml_node config_node = Lx_kit::env().config_rom().xml(); - - /* try using configured mac */ - try { - Xml_node nic_config = config_node.sub_node("nic"); - Xml_node::Attribute mac_node = nic_config.attribute("mac"); - mac_node.value(mac); - } catch (...) { - /* use fallback mac */ - snprint_mac(str, fallback); - Genode::warning("No mac address or wrong format attribute in - using fallback (", Genode::Cstring(str), ")"); - - Genode::memcpy(addr, fallback, ETH_ALEN); - return; - } - - /* use configured mac*/ - Genode::memcpy(addr, mac.addr, ETH_ALEN); - snprint_mac(str, (u8 *)mac.addr); - Genode::log("Using configured mac: ", Genode::Cstring(str)); - -#ifdef GENODE_NET_STAT - _stat.set_mac(mac.addr); -#endif -} - diff --git a/repos/dde_linux/src/drivers/usb/raw/raw.cc b/repos/dde_linux/src/drivers/usb/raw/raw.cc deleted file mode 100644 index b469ef76f0..0000000000 --- a/repos/dde_linux/src/drivers/usb/raw/raw.cc +++ /dev/null @@ -1,1242 +0,0 @@ -/* - * \brief Server side USB session implementation - * \author Sebastian Sumpf - * \date 2014-12-08 - */ - -/* - * Copyright (C) 2014-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "raw.h" -#include -#include - -#include -#include - -/* definition from scsi.h conflicts with USB session timeout error */ -#undef TIMEOUT_ERROR - -using namespace Genode; - -extern "C" int usb_set_configuration(struct usb_device *dev, int configuration); - -constexpr bool verbose_raw = false; - - -namespace Usb { - class Session_component; - class Root; - class Worker; - class Cleaner; -} - -/** - * Keep track of all registered USB devices (via raw driver) - */ -struct Device : List::Element -{ - usb_device *udev; - - static List *list() - { - static List _l; - return &_l; - } - - static Device * device_product(uint16_t vendor, uint16_t product) - { - for (Device *d = list()->first(); d; d = d->next()) { - if (d->udev->descriptor.idVendor == vendor && d->udev->descriptor.idProduct == product) - return d; - } - - return nullptr; - } - - - static Device * device_bus(long bus, long dev) - { - for (Device *d = list()->first(); d; d = d->next()) { - if (d->udev->bus->busnum == bus && d->udev->devnum == dev) - return d; - } - - return nullptr; - } - - static void report_device_list(); - - Device(usb_device *udev) : udev(udev) - { - list()->insert(this); - report_device_list(); - } - - ~Device() - { - list()->remove(this); - report_device_list(); - } - - usb_interface *interface(unsigned index) - { - if (!udev || !udev->actconfig) - return nullptr; - - if (index >= udev->actconfig->desc.bNumInterfaces) - return nullptr; - - usb_interface *iface = udev->actconfig->interface[index]; - return iface; - } - - usb_host_endpoint *endpoint(usb_interface *iface, unsigned alt_setting, - unsigned endpoint_num) - { - return &iface->altsetting[alt_setting].endpoint[endpoint_num]; - } - - Session_label label() - { - if (!udev || !udev->bus) - return Session_label("usb-unknown"); - return Session_label("usb-", udev->bus->busnum, "-", udev->devnum); - } -}; - - -/** - * Handle packet stream request, this way the entrypoint always returns to it's - * server loop - */ -class Usb::Worker : public Genode::Weak_object -{ - private: - - completion _packet_avail; - - Session::Tx::Sink *_sink; - Device *_device = nullptr; - Signal_context_capability _sigh_ready; - Lx::Task *_task = nullptr; - unsigned _p_in_flight = 0; - bool _device_ready = false; - - void _ack_packet(Packet_descriptor &p) - { - _sink->acknowledge_packet(p); - _p_in_flight--; - } - - /** - * Retrieve string descriptor at index given in packet - */ - void _retrieve_string(Packet_descriptor &p) - { - char *buffer = _sink->packet_content(p); - int length; - - if ((length = usb_string(_device->udev, p.string.index, buffer, p.size())) < 0) { - warning("Could not read string descriptor index: ", (unsigned)p.string.index); - p.string.length = 0; - } else { - /* returned length is in bytes (char) */ - p.string.length = length / 2; - p.succeded = true; - } - } - - /** - * Read control transfer - */ - void _ctrl_in(Packet_descriptor &p) - { - void *buf = kmalloc(4096, GFP_NOIO); - - int err = usb_control_msg(_device->udev, usb_rcvctrlpipe(_device->udev, 0), - p.control.request, p.control.request_type, - p.control.value, p.control.index, buf, - p.size(), p.control.timeout); - - if (err > 0 && p.size()) - Genode::memcpy(_sink->packet_content(p), buf, err); - - kfree(buf); - - if (err >= 0) { - p.succeded = true; - p.control.actual_size = err; - } else { - p.control.actual_size = 0; - - if (err == -ENOENT) - p.error = Packet_descriptor::INTERFACE_OR_ENDPOINT_ERROR; - else if ((err == -ENODEV) || (err == -ESHUTDOWN)) - p.error = Packet_descriptor::NO_DEVICE_ERROR; - else if ((err == -EPROTO) || (err == -EILSEQ)) - p.error = Packet_descriptor::PROTOCOL_ERROR; - else if (err == -EPIPE) - p.error = Packet_descriptor::STALL_ERROR; - else if (err == -ETIMEDOUT) - p.error = Packet_descriptor::TIMEOUT_ERROR; - else { - Genode::error(__func__, ": unhandled error: ", err); - p.error = Packet_descriptor::UNKNOWN_ERROR; - } - } - } - - /** - * Write control transfer - */ - void _ctrl_out(Packet_descriptor &p) - { - void *buf = kmalloc(4096, GFP_NOIO); - - if (p.size()) - Genode::memcpy(buf, _sink->packet_content(p), p.size()); - - int err = usb_control_msg(_device->udev, usb_sndctrlpipe(_device->udev, 0), - p.control.request, p.control.request_type, - p.control.value, p.control.index, buf, p.size(), - p.control.timeout); - - if (err >= 0) { - p.succeded = true; - p.control.actual_size = err; - - if (p.control.request == USB_REQ_CLEAR_FEATURE && - p.control.value == USB_ENDPOINT_HALT) { - usb_reset_endpoint(_device->udev, p.control.index); - } - } else { - p.control.actual_size = 0; - - if (err == -ENOENT) - p.error = Packet_descriptor::INTERFACE_OR_ENDPOINT_ERROR; - else if ((err == -ENODEV) || (err == -ESHUTDOWN)) - p.error = Packet_descriptor::NO_DEVICE_ERROR; - else if ((err == -EPROTO) || (err == -EILSEQ)) - p.error = Packet_descriptor::PROTOCOL_ERROR; - else if (err == -EPIPE) - p.error = Packet_descriptor::STALL_ERROR; - else if (err == -ETIMEDOUT) - p.error = Packet_descriptor::TIMEOUT_ERROR; - else { - Genode::error(__func__, ": unhandled error: ", err); - p.error = Packet_descriptor::UNKNOWN_ERROR; - } - } - - kfree(buf); - } - - /** - * Asynchronous transfer helpers - */ - struct Complete_data - { - Weak_ptr worker; - Packet_descriptor packet; - - Complete_data(Weak_ptr &w, Packet_descriptor &p) - : worker(w), packet(p) { } - }; - - Complete_data * alloc_complete_data(Packet_descriptor &p) - { - void * data = kmalloc(sizeof(Complete_data), GFP_KERNEL); - construct_at(data, this->weak_ptr(), p); - return reinterpret_cast(data); - } - - static void free_complete_data(Complete_data *data) - { - data->packet.~Packet_descriptor(); - data->worker.~Weak_ptr(); - kfree (data); - } - - void _async_finish(Packet_descriptor &p, urb *urb, bool read) - { - if (urb->status == 0) { - p.transfer.actual_size = urb->actual_length; - p.succeded = true; - - if (read) { - /* make sure the client sees the actual amount of data */ - for (int i = 0; i < urb->number_of_packets; i++) { - p.transfer.actual_packet_size[i] = urb->iso_frame_desc[i].actual_length; - } - - /* - * We have to copy the whole transfer buffer because the - * controller used the offsets into the original buffer to - * store the data. - */ - Genode::memcpy(_sink->packet_content(p), urb->transfer_buffer, - urb->transfer_buffer_length); - } - } else if (urb->status == -ESHUTDOWN) { - p.error = Packet_descriptor::NO_DEVICE_ERROR; - } else if ((urb->status == -EPROTO) || (urb->status == -EILSEQ)) { - p.error = Packet_descriptor::PROTOCOL_ERROR; - } else if (urb->status == -EPIPE) { - p.error = Packet_descriptor::STALL_ERROR; - } else { - Genode::error(__func__, ": unhandled error: ", urb->status); - p.error = Packet_descriptor::UNKNOWN_ERROR; - } - - _ack_packet(p); - } - - static void _async_complete(urb *urb) - { - Complete_data *data = (Complete_data *)urb->context; - - { - Locked_ptr worker(data->worker); - - if (worker.valid()) - worker->_async_finish(data->packet, urb, - !!(data->packet.transfer.ep & USB_DIR_IN)); - } - - free_complete_data(data); - dma_free(urb->transfer_buffer); - usb_free_urb(urb); - } - - /** - * Bulk transfer - */ - bool _bulk(Packet_descriptor &p, bool read) - { - unsigned pipe; - void *buf = dma_malloc(p.size()); - - if (read) - pipe = usb_rcvbulkpipe(_device->udev, p.transfer.ep); - else { - pipe = usb_sndbulkpipe(_device->udev, p.transfer.ep); - Genode::memcpy(buf, _sink->packet_content(p), p.size()); - } - - urb *bulk_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!bulk_urb) { - error("Failed to allocate bulk URB"); - dma_free(buf); - p.error = Usb::Packet_descriptor::MEMORY_ERROR; - return false; - } - - Complete_data *data = alloc_complete_data(p); - - usb_fill_bulk_urb(bulk_urb, _device->udev, pipe, buf, p.size(), - _async_complete, data); - - int ret = usb_submit_urb(bulk_urb, GFP_KERNEL); - if (ret != 0) { - if (ret == -ENOENT) - p.error = Packet_descriptor::INTERFACE_OR_ENDPOINT_ERROR; - else if ((ret == -ENODEV) || (ret == -ESHUTDOWN)) - p.error = Packet_descriptor::NO_DEVICE_ERROR; - else { - Genode::error(__func__, ": unhandled error: ", ret); - p.error = Packet_descriptor::UNKNOWN_ERROR; - } - - free_complete_data(data); - usb_free_urb(bulk_urb); - dma_free(buf); - return false; - } - - return true; - } - - /** - * IRQ transfer - */ - bool _irq(Packet_descriptor &p, bool read) - { - unsigned pipe; - void *buf = dma_malloc(p.size()); - - if (read) - pipe = usb_rcvintpipe(_device->udev, p.transfer.ep); - else { - pipe = usb_sndintpipe(_device->udev, p.transfer.ep); - Genode::memcpy(buf, _sink->packet_content(p), p.size()); - } - - urb *irq_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!irq_urb) { - error("Failed to allocate interrupt URB"); - dma_free(buf); - p.error = Usb::Packet_descriptor::MEMORY_ERROR; - return false; - } - - Complete_data *data = alloc_complete_data(p); - - int polling_interval; - - if (p.transfer.polling_interval == Usb::Packet_descriptor::DEFAULT_POLLING_INTERVAL) { - - usb_host_endpoint *ep = read ? _device->udev->ep_in[p.transfer.ep & 0x0f] - : _device->udev->ep_out[p.transfer.ep & 0x0f]; - - if (!ep) { - error("could not get ep: ", p.transfer.ep); - dma_free(buf); - p.error = Usb::Packet_descriptor::INTERFACE_OR_ENDPOINT_ERROR; - return false; - } - - polling_interval = ep->desc.bInterval; - - } else - polling_interval = p.transfer.polling_interval; - - usb_fill_int_urb(irq_urb, _device->udev, pipe, buf, p.size(), - _async_complete, data, polling_interval); - - int ret = usb_submit_urb(irq_urb, GFP_KERNEL); - if (ret != 0) { - if (ret == -ENOENT) - p.error = Packet_descriptor::INTERFACE_OR_ENDPOINT_ERROR; - else if ((ret == -ENODEV) || (ret == -ESHUTDOWN)) - p.error = Packet_descriptor::NO_DEVICE_ERROR; - else { - Genode::error(__func__, ": unhandled error: ", ret); - p.error = Packet_descriptor::UNKNOWN_ERROR; - } - - free_complete_data(data); - usb_free_urb(irq_urb); - dma_free(buf); - return false; - } - - return true; - } - - /** - * Isochronous transfer - */ - bool _isoc(Packet_descriptor &p, bool read) - { - unsigned pipe; - usb_host_endpoint *ep; - void *buf = dma_malloc(p.size()); - - if (read) { - pipe = usb_rcvisocpipe(_device->udev, p.transfer.ep); - ep = _device->udev->ep_in[p.transfer.ep & 0x0f]; - } - else { - pipe = usb_sndisocpipe(_device->udev, p.transfer.ep); - ep = _device->udev->ep_out[p.transfer.ep & 0x0f]; - Genode::memcpy(buf, _sink->packet_content(p), p.size()); - } - - if (!ep) { - error("could not get ep: ", p.transfer.ep); - dma_free(buf); - p.error = Usb::Packet_descriptor::INTERFACE_OR_ENDPOINT_ERROR; - return false; - } - - urb *urb = usb_alloc_urb(p.transfer.number_of_packets, GFP_KERNEL); - if (!urb) { - error("Failed to allocate isochronous URB"); - dma_free(buf); - p.error = Usb::Packet_descriptor::MEMORY_ERROR; - return false; - } - - Complete_data *data = alloc_complete_data(p); - urb->dev = _device->udev; - urb->pipe = pipe; - urb->start_frame = -1; - urb->stream_id = 0; - urb->transfer_buffer = buf; - urb->transfer_buffer_length = p.size(); - urb->number_of_packets = p.transfer.number_of_packets; - urb->interval = 1 << min(15, ep->desc.bInterval - 1); - urb->context = (void *)data; - urb->transfer_flags = URB_ISO_ASAP | (read ? URB_DIR_IN : URB_DIR_OUT); - urb->complete = _async_complete; - - unsigned offset = 0; - for (int i = 0; i < p.transfer.number_of_packets; i++) { - urb->iso_frame_desc[i].offset = offset; - urb->iso_frame_desc[i].length = p.transfer.packet_size[i]; - offset += p.transfer.packet_size[i]; - } - - int ret = usb_submit_urb(urb, GFP_KERNEL); - if (ret == 0) - return true; - - if (ret == -ENOENT) - p.error = Packet_descriptor::INTERFACE_OR_ENDPOINT_ERROR; - else if ((ret == -ENODEV) || (ret == -ESHUTDOWN)) - p.error = Packet_descriptor::NO_DEVICE_ERROR; - else { - Genode::error(__func__, ": unhandled error: ", ret); - p.error = Packet_descriptor::UNKNOWN_ERROR; - } - - free_complete_data(data); - usb_free_urb(urb); - dma_free(buf); - return false; - } - - /** - * Change alternate settings for device - */ - void _alt_setting(Packet_descriptor &p) - { - int err = usb_set_interface(_device->udev, p.interface.number, - p.interface.alt_setting); - if (!err) - p.succeded = true; - else - Genode::error(__func__, ": unhandled error: ", err); - } - - /** - * Set configuration - */ - void _config(Packet_descriptor &p) - { - usb_host_config *config = _device->udev->actconfig; - - if (config) { - for (unsigned i = 0; i < config->desc.bNumInterfaces; i++) { - if (usb_interface_claimed(config->interface[i])) { - error("There are interfaces claimed, won't set configuration"); - return; - } - } - } - - int err = usb_set_configuration(_device->udev, p.number); - - if (!err) - p.succeded = true; - else - Genode::error(__func__, ": unhandled error: ", err); - } - - /** - * Release interface - */ - void _release_interface(Packet_descriptor &p) - { - usb_interface *iface = _device->interface(p.number); - - if (!iface) - return; - - usb_driver_release_interface(&raw_intf_driver, iface); - p.succeded = true; - } - - /** - * Dispatch incoming packet types - */ - void _dispatch() - { - /* - * Get packets until there are no more free ack slots or avaiable - * packets - */ - while (_p_in_flight < _sink->ack_slots_free() && _sink->packet_avail()) - { - Packet_descriptor p = _sink->get_packet(); - - if (verbose_raw) - log("PACKET: ", (unsigned)p.type, " first value: ", Hex(p.number)); - - _p_in_flight++; - - if (!_device || !_device->udev || - _device->udev->state == USB_STATE_NOTATTACHED) { - p.error = Packet_descriptor::NO_DEVICE_ERROR; - _ack_packet(p); - continue; - } - - if (!_sink->packet_valid(p)) { - p.error = Packet_descriptor::PACKET_INVALID_ERROR; - _ack_packet(p); - continue; - } - - switch (p.type) { - - case Packet_descriptor::STRING: - _retrieve_string(p); - break; - - case Packet_descriptor::CTRL: - if (p.control.request_type & Usb::ENDPOINT_IN) - _ctrl_in(p); - else - _ctrl_out(p); - break; - - case Packet_descriptor::BULK: - if (_bulk(p, p.read_transfer())) - continue; - break; - - case Packet_descriptor::IRQ: - if (_irq(p, p.read_transfer())) - continue; - break; - - case Packet_descriptor::ISOC: - if (_isoc(p, p.read_transfer())) - continue; - break; - - case Packet_descriptor::ALT_SETTING: - _alt_setting(p); - break; - - case Packet_descriptor::CONFIG: - _config(p); - break; - - case Packet_descriptor::RELEASE_IF: - _release_interface(p); - break; - } - - _ack_packet(p); - } - } - - void _wait_for_device() - { - wait_queue_head_t wait; - _wait_event(wait, _device); - _wait_event(wait, _device->udev->actconfig); - - if (_sigh_ready.valid()) - Signal_transmitter(_sigh_ready).submit(1); - - _device_ready = true; - } - - /** - * Wait for packets - */ - void _wait() - { - /* wait for device to become ready */ - init_completion(&_packet_avail); - _wait_for_device(); - - while (true) { - wait_for_completion(&_packet_avail); - _dispatch(); - } - } - - public: - - static void run(void *worker) - { - Worker *w = static_cast(worker); - w->_wait(); - } - - Worker(Session::Tx::Sink *sink) - : _sink(sink) - { } - - ~Worker() - { - Weak_object::lock_for_destruction(); - } - - void start() - { - if (!_task) { - _task = new (Lx::Malloc::mem()) Lx::Task(run, this, "raw_worker", - Lx::Task::PRIORITY_2, - Lx::scheduler()); - if (!Lx::scheduler().active()) { - Lx::scheduler().schedule(); - } - } - } - - void stop() - { - if (_task) { - Lx::scheduler().remove(_task); - destroy(Lx::Malloc::mem(), _task); - _task = nullptr; - } - } - - void packet_avail() { ::complete(&_packet_avail); } - - void device(Device *device, Signal_context_capability sigh_ready = Signal_context_capability()) - { - _device = device; - _sigh_ready = sigh_ready; - } - - bool device_ready() { return _device_ready; } -}; - - -struct Interface : List<::Interface>::Element -{ - usb_interface *iface; - - Interface(usb_interface *iface) : iface(iface) { } -}; - - -/** - * Asynchronous USB-interface release - */ -class Usb::Cleaner : List<::Interface> -{ - private: - - static void _run(void *c) - { - Cleaner *cleaner = (Cleaner *)c; - - while (true) { - cleaner->_task.block_and_schedule(); - - while (::Interface *interface = cleaner->first()) { - usb_driver_release_interface(&raw_intf_driver, interface->iface); - cleaner->remove(interface); - destroy(Lx::Malloc::mem(), interface); - } - } - } - - Lx::Task _task { _run, this, "raw_cleaner", Lx::Task::PRIORITY_2, - Lx::scheduler() }; - - public: - - void schedule_release(usb_interface *iface) - { - ::Interface *interface = new(Lx::Malloc::mem()) ::Interface(iface); - insert(interface); - _task.unblock(); - Lx::scheduler().schedule(); - } -}; - - -/***************** - ** USB session ** - *****************/ - -class Usb::Session_component : public Session_rpc_object, - public List::Element -{ - private: - - Genode::Entrypoint &_ep; - unsigned long _vendor; - unsigned long _product; - long _bus = 0; - long _dev = 0; - Device *_device = nullptr; - Signal_context_capability _sigh_state_change; - Io_signal_handler _packet_avail; - Io_signal_handler _ready_ack; - Worker _worker; - Ram_dataspace_capability _tx_ds; - Usb::Cleaner &_cleaner; - - - void _signal_state_change() - { - if (_sigh_state_change.valid()) - Signal_transmitter(_sigh_state_change).submit(1); - } - - void _receive() - { - _worker.packet_avail(); - Lx::scheduler().schedule(); - } - - public: - - enum State { - DEVICE_ADD, - DEVICE_REMOVE, - }; - - Session_component(Genode::Ram_dataspace_capability tx_ds, - Genode::Entrypoint &ep, - Genode::Region_map &rm, - unsigned long vendor, unsigned long product, - long bus, long dev, Usb::Cleaner &cleaner) - : Session_rpc_object(tx_ds, ep.rpc_ep(), rm), - _ep(ep), _vendor(vendor), _product(product), _bus(bus), _dev(dev), - _packet_avail(ep, *this, &Session_component::_receive), - _ready_ack(ep, *this, &Session_component::_receive), - _worker(sink()), _tx_ds(tx_ds), _cleaner(cleaner) - { - Device *device; - if (bus && dev) - device = Device::device_bus(bus, dev); - else - device = Device::device_product(_vendor, _product); - if (device) { - state_change(DEVICE_ADD, device); - } - - /* register signal handlers */ - _tx.sigh_packet_avail(_packet_avail); - } - - ~Session_component() - { - /* release claimed interfaces */ - if (_device && _device->udev && _device->udev->actconfig) { - unsigned const num = _device->udev->actconfig->desc.bNumInterfaces; - for (unsigned i = 0; i < num; i++) - release_interface(i); - } - - _worker.stop(); - } - - /*********************** - ** Session interface ** - ***********************/ - - bool plugged() { return _device != nullptr; } - - void claim_interface(unsigned interface_num) override - { - if (!_device) - throw Device_not_found(); - - usb_interface *iface = _device->interface(interface_num); - if (!iface) - throw Interface_not_found(); - - if (usb_driver_claim_interface(&raw_intf_driver, iface, nullptr)) - throw Interface_already_claimed(); - } - - void release_interface(unsigned interface_num) override - { - if (!_device) - throw Device_not_found(); - - usb_interface *iface = _device->interface(interface_num); - if (!iface) - throw Interface_not_found(); - - _cleaner.schedule_release(iface); - } - - void config_descriptor(Device_descriptor *device_descr, - Config_descriptor *config_descr) override - { - if (!_device) - throw Device_not_found(); - - Genode::memcpy(device_descr, &_device->udev->descriptor, sizeof(usb_device_descriptor)); - - if (_device->udev->actconfig) - Genode::memcpy(config_descr, &_device->udev->actconfig->desc, sizeof(usb_config_descriptor)); - else - Genode::memset(config_descr, 0, sizeof(usb_config_descriptor)); - - device_descr->num = _device->udev->devnum; - device_descr->speed = _device->udev->speed; - } - - unsigned alt_settings(unsigned index) override - { - if (!_device) - throw Device_not_found(); - - usb_interface *iface = _device->interface(index); - if (!iface) - throw Interface_not_found(); - - return iface->num_altsetting; - } - - void interface_descriptor(unsigned index, unsigned alt_setting, - Interface_descriptor *interface_descr) override - { - if (!_device) - throw Device_not_found(); - - usb_interface *iface = _device->interface(index); - if (!iface) - throw Interface_not_found(); - - Genode::memcpy(interface_descr, &iface->altsetting[alt_setting].desc, - sizeof(usb_interface_descriptor)); - - if (&iface->altsetting[alt_setting] == iface->cur_altsetting) - interface_descr->active = true; - } - - bool interface_extra(unsigned index, unsigned alt_setting, - Interface_extra *interface_data) - { - if (!_device) - throw Device_not_found(); - - usb_interface *iface = _device->interface(index); - if (!iface) - throw Interface_not_found(); - - Genode::uint8_t length = iface->altsetting[alt_setting].extralen; - if (length == 0) return false; - - if (length > sizeof(Interface_extra::data)) - length = sizeof(Interface_extra::data); - - Genode::memcpy(interface_data->data, iface->altsetting[alt_setting].extra, - length); - - interface_data->length = length; - return true; - } - - void endpoint_descriptor(unsigned interface_num, - unsigned alt_setting, - unsigned endpoint_num, - Endpoint_descriptor *endpoint_descr) override - { - if (!_device || !_device->udev) - throw Device_not_found(); - - usb_interface *iface = usb_ifnum_to_if(_device->udev, interface_num); - if (!iface) - throw Interface_not_found(); - - Genode::memcpy(endpoint_descr, &_device->endpoint(iface, alt_setting, - endpoint_num)->desc, sizeof(usb_endpoint_descriptor)); - } - - /********************* - ** Local interface ** - *********************/ - - bool session_device(Device *device) - { - usb_device_descriptor *descr = &device->udev->descriptor; - return (descr->idVendor == _vendor && descr->idProduct == _product) - || (_bus && _dev && _bus == device->udev->bus->busnum && - _dev == device->udev->devnum) ? true : false; - } - - bool state_change(State state, Device *device) - { - switch (state) { - case DEVICE_ADD: - if (!session_device(device)) - return false; - - if (_device) - warning("Device type already present (vendor: ", - Hex(device->udev->descriptor.idVendor), - " product: ", Hex(device->udev->descriptor.idProduct), - ") Overwrite!"); - - _device = device; - _worker.device(_device, _sigh_state_change); - _worker.start(); - return true; - - case DEVICE_REMOVE: - if (!session_device(device)) - return false; - _device = nullptr; - _worker.stop(); - _signal_state_change(); - return true; - } - - return false; - } - - void sigh_state_change(Signal_context_capability sigh) - { - _sigh_state_change = sigh; - - if (_worker.device_ready()) - Signal_transmitter(_sigh_state_change).submit(1); - } - - Ram_dataspace_capability tx_ds() { return _tx_ds; } -}; - - -struct Session : public List -{ - static Session *list() - { - static Session _l; - return &_l; - } - - void state_change(Usb::Session_component::State state, Device *device) - { - for (Usb::Session_component *session = list()->first(); session; session = session->next()) - if (session->state_change(state, device)) - return; - } -}; - - -class Usb::Root : public Genode::Root_component -{ - private: - - Genode::Env &_env; - - Genode::Signal_handler _config_handler = { - _env.ep(), *this, &Usb::Root::_handle_config }; - - Genode::Reporter _config_reporter { _env, "config" }; - - Genode::Reporter _device_list_reporter { - _env, "devices", "devices", 512*1024 }; - - Usb::Cleaner _cleaner; - - void _handle_config() - { - Lx_kit::env().config_rom().update(); - - Genode::Xml_node config = Lx_kit::env().config_rom().xml(); - - if (!_config_reporter.enabled()) - _config_reporter.enabled(true); - - bool const uhci = config.attribute_value("uhci", false); - bool const ehci = config.attribute_value("ehci", false); - bool const xhci = config.attribute_value("xhci", false); - bool const ohci = config.attribute_value("ohci", false); - - Genode::Reporter::Xml_generator xml(_config_reporter, [&] { - if (uhci) xml.attribute("uhci", "yes"); - if (ehci) xml.attribute("ehci", "yes"); - if (xhci) xml.attribute("xhci", "yes"); - if (ohci) xml.attribute("ohci", "yes"); - - config.with_raw_content([&] (char const *start, size_t length) { - xml.append(start, length); }); - }); - } - - protected: - - Session_component *_create_session(const char *args) - { - using namespace Genode; - using Genode::size_t; - - Session_label const label = label_from_args(args); - try { - Xml_node config_node = Lx_kit::env().config_rom().xml(); - Xml_node raw = config_node.sub_node("raw"); - Genode::Session_policy policy(label, raw); - - size_t ram_quota = Arg_string::find_arg(args, "ram_quota" ).ulong_value(0); - size_t tx_buf_size = Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); - - unsigned long vendor = policy.attribute_value("vendor_id", 0); - unsigned long product = policy.attribute_value("product_id", 0); - unsigned long bus = policy.attribute_value("bus", 0); - unsigned long dev = policy.attribute_value("dev", 0); - - /* check session quota */ - size_t session_size = max(4096, sizeof(Session_component)); - if (ram_quota < session_size) - throw Insufficient_ram_quota(); - - if (tx_buf_size > ram_quota - session_size) { - error("Insufficient 'ram_quota',got ", ram_quota, " need ", - tx_buf_size + session_size); - throw Insufficient_ram_quota(); - } - - Ram_dataspace_capability tx_ds = _env.ram().alloc(tx_buf_size); - Session_component *session = new (md_alloc()) - Session_component(tx_ds, _env.ep(), _env.rm(), vendor, product, bus, dev, _cleaner); - ::Session::list()->insert(session); - return session; - } - catch (Genode::Session_policy::No_policy_defined) { - error("Invalid session request, no matching policy for '", - label.string(), "'"); - throw Genode::Service_denied(); - } - } - - void _destroy_session(Session_component *session) - { - Ram_dataspace_capability tx_ds = session->tx_ds(); - - ::Session::list()->remove(session); - Genode::Root_component::_destroy_session(session); - - _env.ram().free(tx_ds); - } - - public: - - Root(Genode::Env &env, - Genode::Allocator &md_alloc, - bool report_device_list) - : Genode::Root_component(env.ep(), md_alloc), - _env(env) - { - Lx_kit::env().config_rom().sigh(_config_handler); - _device_list_reporter.enabled(report_device_list); - } - - Genode::Reporter &device_list_reporter() - { - return _device_list_reporter; - } -}; - - -static Genode::Constructible root; - - -void Raw::init(Genode::Env &env, bool report_device_list) -{ - root.construct(env, Lx::Malloc::mem(), report_device_list); - env.parent().announce(env.ep().manage(*root)); -} - - -void Device::report_device_list() -{ - if (!root->device_list_reporter().enabled()) - return; - - Genode::Reporter::Xml_generator xml(root->device_list_reporter(), [&] () - { - - for (Device *d = list()->first(); d; d = d->next()) { - usb_interface *iface = d->interface(0); - - if (!iface || !iface->cur_altsetting || !d->udev || !d->udev->bus) { - Genode::warning("device ", d->label().string(), " state incomplete"); - continue; - } - - xml.node("device", [&] () - { - char buf[16]; - - unsigned const bus = d->udev->bus->busnum; - unsigned const dev = d->udev->devnum; - - xml.attribute("label", d->label().string()); - - Genode::snprintf(buf, sizeof(buf), "0x%4x", - d->udev->descriptor.idVendor); - xml.attribute("vendor_id", buf); - - Genode::snprintf(buf, sizeof(buf), "0x%4x", - d->udev->descriptor.idProduct); - xml.attribute("product_id", buf); - - Genode::snprintf(buf, sizeof(buf), "0x%4x", bus); - xml.attribute("bus", buf); - - Genode::snprintf(buf, sizeof(buf), "0x%4x", dev); - xml.attribute("dev", buf); - - Genode::snprintf(buf, sizeof(buf), "0x%02x", - iface->cur_altsetting->desc.bInterfaceClass); - xml.attribute("class", buf); - }); - } - }); -} - -/***************** - ** C interface ** - *****************/ - -int raw_notify(struct notifier_block *nb, unsigned long action, void *data) -{ - struct usb_device *udev = (struct usb_device*)data; - - if (verbose_raw) - log("RAW: ",action == USB_DEVICE_ADD ? "Add" : "Remove", - " vendor: ", Hex(udev->descriptor.idVendor), - " product: ", Hex(udev->descriptor.idProduct)); - - - switch (action) { - - case USB_DEVICE_ADD: - { - ::Session::list()->state_change(Usb::Session_component::DEVICE_ADD, - new (Lx::Malloc::mem()) Device(udev)); - break; - } - - case USB_DEVICE_REMOVE: - { - Device *dev = Device::device_bus(udev->bus->busnum, - udev->devnum); - if (dev) { - ::Session::list()->state_change(Usb::Session_component::DEVICE_REMOVE, dev); - destroy(Lx::Malloc::mem(), dev); - } - break; - } - - case USB_BUS_ADD: - break; - - case USB_BUS_REMOVE: - break; - } - - return NOTIFY_OK; -} diff --git a/repos/dde_linux/src/drivers/usb/raw/raw.h b/repos/dde_linux/src/drivers/usb/raw/raw.h deleted file mode 100644 index 672717236a..0000000000 --- a/repos/dde_linux/src/drivers/usb/raw/raw.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _RAW_H_ -#define _RAW_H_ - -struct usb_device; -struct usb_driver; - -extern struct usb_device_driver raw_driver; -extern struct usb_driver raw_intf_driver; - -int raw_notify(struct notifier_block *nb, unsigned long action, void *data); - -#endif /* _RAW_H_ */ diff --git a/repos/dde_linux/src/drivers/usb/raw/raw_driver.c b/repos/dde_linux/src/drivers/usb/raw/raw_driver.c deleted file mode 100644 index 5d3b566a4b..0000000000 --- a/repos/dde_linux/src/drivers/usb/raw/raw_driver.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * \brief Low level USB access driver - * \author Sebastian Sumpf - * \date 2014-11-11 - */ - -/* - * Copyright (C) 2014-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include "raw.h" - -static int raw_probe(struct usb_device *udev) -{ - printk("RAW: vendor: %x product: %x dev %p\n", - udev->descriptor.idVendor, udev->descriptor.idProduct, udev); - - return -ENODEV; -} - -static void raw_disconnect(struct usb_device *udev) -{ - printk("driver disconnect called\n"); -} - - -struct usb_device_driver raw_driver = -{ - .name = "raw", - .probe = raw_probe, - .disconnect = raw_disconnect, - .supports_autosuspend = 0, -}; - - -static int raw_intf_probe(struct usb_interface *intf, - struct usb_device_id const *id) -{ - struct usb_device *udev = interface_to_usbdev(intf); - - printk("RAW_INTF: vendor: %04x product: %04x\n", udev->descriptor.idVendor, - udev->descriptor.idProduct); - - return -ENODEV; -} - -void raw_intf_disconnect(struct usb_interface *intf) { } - -static const struct usb_device_id raw_intf_id_table[] = { - { .driver_info = 1 } -}; - - -struct usb_driver raw_intf_driver = -{ - .name = "rawintf", - .probe = raw_intf_probe, - .disconnect = raw_intf_disconnect, - .supports_autosuspend = 0, -}; - - -struct notifier_block usb_nb = -{ - .notifier_call = raw_notify -}; - - -static int raw_driver_init(void) -{ - int err; - - if ((err = usb_register_device_driver(&raw_driver, THIS_MODULE))) - return err; - - printk("RAW: driver registered\n"); - - if ((err = usb_register(&raw_intf_driver))) - return err; - - printk("RAW: interface driver registered\n"); - - usb_register_notify(&usb_nb); - - printk("RAW: notify function registered\n"); - - return 0; -} - -module_init(raw_driver_init); diff --git a/repos/dde_linux/src/drivers/usb/spec/arm/platform_device.cc b/repos/dde_linux/src/drivers/usb/spec/arm/platform_device.cc deleted file mode 100644 index 842d0ef253..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/arm/platform_device.cc +++ /dev/null @@ -1,235 +0,0 @@ -/* - * \brief Linux platform_device emulation - * \author Sebastian Sumpf - * \date 2012-06-18 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include - -#include -#include - -#define to_platform_driver(drv) (container_of((drv), struct platform_driver, \ - driver)) - -static int platform_match(struct device *dev, struct device_driver *drv) -{ - if (!dev->name) - return 0; - - - printk("MATCH %s %s\n", dev->name, drv->name); - return (strcmp(dev->name, drv->name) == 0); -} - - -static int platform_drv_probe(struct device *_dev) -{ - struct platform_driver *drv = to_platform_driver(_dev->driver); - struct platform_device *dev = to_platform_device(_dev); - - return drv->probe(dev); -} - - -struct bus_type platform_bus_type = { - .name = "platform", -}; - - -int platform_driver_register(struct platform_driver *drv) -{ - /* init plarform_bus_type */ - platform_bus_type.match = platform_match; - platform_bus_type.probe = platform_drv_probe; - - drv->driver.bus = &platform_bus_type; - if (drv->probe) - drv->driver.probe = platform_drv_probe; - - printk("Register: %s\n", drv->driver.name); - return driver_register(&drv->driver); -} - - -struct resource *platform_get_resource(struct platform_device *dev, - unsigned int type, unsigned int num) -{ - unsigned i; - - for (i = 0; i < dev->num_resources; i++) { - struct resource *r = &dev->resource[i]; - - if ((type & r->flags) && num-- == 0) - return r; - } - - return NULL; -} - - -struct resource *platform_get_resource_byname(struct platform_device *dev, - unsigned int type, - const char *name) -{ - unsigned i; - - for (i = 0; i < dev->num_resources; i++) { - struct resource *r = &dev->resource[i]; - - if (type == r->flags && !strcmp(r->name, name)) - return r; - } - - return NULL; -} - - -int platform_get_irq_byname(struct platform_device *dev, const char *name) -{ - struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); - return r ? r->start : -1; -} - - -int platform_get_irq(struct platform_device *dev, unsigned int num) -{ - struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, 0); - return r ? r->start : -1; -} - - -int platform_device_register(struct platform_device *pdev) -{ - pdev->dev.bus = &platform_bus_type; - pdev->dev.name = pdev->name; - /*Set parent to ourselfs */ - if (!pdev->dev.parent) - pdev->dev.parent = &pdev->dev; - device_add(&pdev->dev); - return 0; -} - - -struct platform_device *platform_device_alloc(const char *name, int id) -{ - platform_device *pdev = (platform_device *)kzalloc(sizeof(struct platform_device), GFP_KERNEL); - - if (!pdev) - return 0; - - int len = strlen(name); - pdev->name = (char *)kzalloc(len + 1, GFP_KERNEL); - - if (!pdev->name) { - kfree(pdev); - return 0; - } - - memcpy(pdev->name, name, len); - pdev->name[len] = 0; - pdev->id = id; - - return pdev; -} - - -int platform_device_add_data(struct platform_device *pdev, const void *data, - size_t size) -{ - void *d = NULL; - - if (data && !(d = kmemdup(data, size, GFP_KERNEL))) - return -ENOMEM; - - kfree(pdev->dev.platform_data); - pdev->dev.platform_data = d; - - return 0; -} - - -int platform_device_add(struct platform_device *pdev) -{ - return platform_device_register(pdev); -} - -int platform_device_add_resources(struct platform_device *pdev, - const struct resource *res, unsigned int num) -{ - struct resource *r = NULL; - - if (res) { - r = (resource *)kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL); - if (!r) - return -ENOMEM; - } - - kfree(pdev->resource); - pdev->resource = r; - pdev->num_resources = num; - return 0; -} - - -void *platform_get_drvdata(const struct platform_device *pdev) -{ - return dev_get_drvdata(&pdev->dev); -} - - -void platform_set_drvdata(struct platform_device *pdev, void *data) -{ - dev_set_drvdata(&pdev->dev, data); -} - - -/********************** - ** asm-generic/io.h ** - **********************/ - -void *_ioremap(phys_addr_t phys_addr, unsigned long size, int wc) -{ - try { - Genode::Attached_io_mem_dataspace *ds = new(Lx::Malloc::mem()) - Genode::Attached_io_mem_dataspace(Lx_kit::env().env(), phys_addr, size, !!wc); - return ds->local_addr(); - } catch (...) { - panic("Failed to request I/O memory: [%lx,%lx)", phys_addr, phys_addr + size); - return 0; - } -} - - -void *ioremap(phys_addr_t offset, unsigned long size) -{ - return _ioremap(offset, size, 0); -} - - -void *devm_ioremap(struct device *dev, resource_size_t offset, - unsigned long size) -{ - return _ioremap(offset, size, 0); -} - - -void *devm_ioremap_nocache(struct device *dev, resource_size_t offset, - unsigned long size) -{ - return _ioremap(offset, size, 0); -} - - -void *devm_ioremap_resource(struct device *dev, struct resource *res) -{ - return _ioremap(res->start, res->end - res->start, 0); -} diff --git a/repos/dde_linux/src/drivers/usb/spec/arm/platform_generic.cc b/repos/dde_linux/src/drivers/usb/spec/arm/platform_generic.cc deleted file mode 100644 index 13523702da..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/arm/platform_generic.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* - * \brief ARM specific implemenations used on all SOCs - * \author Sebastian Sumpf - * \date 2016-04-25 - */ - -/* - * Copyright (C) 2016-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include - -#include -#include -#include -#include - - -/**************************** - ** lx_kit/backend_alloc.h ** - ****************************/ - -void backend_alloc_init(Genode::Env&, Genode::Ram_allocator&, - Genode::Allocator&) -{ - /* intentionally left blank */ -} - - -Genode::Ram_dataspace_capability -Lx::backend_alloc(Genode::addr_t size, Genode::Cache cache) { - return Lx_kit::env().env().ram().alloc(size, cache); } - - -void Lx::backend_free(Genode::Ram_dataspace_capability cap) { - return Lx_kit::env().env().ram().free(cap); } - - -/*********************** - ** linux/interrupt.h ** - ***********************/ - -extern "C" int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, - const char *name, void *dev) -{ - struct Irq : Genode::List::Element { - unsigned const nr; - Genode::Irq_connection irq_con { Lx_kit::env().env(), nr }; - Irq(unsigned const irq, Genode::List & list) - : nr(irq) { list.insert(this); } - }; - - static Genode::List irq_list; - - Irq * i = irq_list.first(); - for (; i; i = i->next()) { if (i->nr == irq) break; } - if (!i) i = new (Lx_kit::env().heap()) Irq(irq, irq_list); - - Lx::Irq::irq().request_irq(i->irq_con.cap(), irq, handler, dev); - - return 0; -} diff --git a/repos/dde_linux/src/drivers/usb/spec/arm/target.inc b/repos/dde_linux/src/drivers/usb/spec/arm/target.inc deleted file mode 100644 index 0d6974c10d..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/arm/target.inc +++ /dev/null @@ -1,11 +0,0 @@ -include $(REP_DIR)/src/drivers/usb/target.inc - -SRC_CC += platform_device.cc platform_generic.cc - -INC_DIR += $(LIB_INC_DIR)/spec/arm -INC_DIR += $(REP_DIR)/src/include/spec/arm - -vpath platform_device.cc $(LIB_DIR)/spec/arm -vpath platform_generic.cc $(LIB_DIR)/spec/arm - -# vi:set ft=make : diff --git a/repos/dde_linux/src/drivers/usb/spec/arm_v6/target.inc b/repos/dde_linux/src/drivers/usb/spec/arm_v6/target.inc deleted file mode 100644 index 6a81ffd874..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/arm_v6/target.inc +++ /dev/null @@ -1,3 +0,0 @@ -include $(REP_DIR)/src/drivers/usb/spec/arm/target.inc - -INC_DIR += $(LIB_INC_DIR)/spec/arm_v6 diff --git a/repos/dde_linux/src/drivers/usb/spec/arm_v7/target.inc b/repos/dde_linux/src/drivers/usb/spec/arm_v7/target.inc deleted file mode 100644 index 04b6884ae9..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/arm_v7/target.inc +++ /dev/null @@ -1,3 +0,0 @@ -include $(REP_DIR)/src/drivers/usb/spec/arm/target.inc - -INC_DIR += $(LIB_INC_DIR)/spec/arm_v7 diff --git a/repos/dde_linux/src/drivers/usb/spec/rpi/platform.cc b/repos/dde_linux/src/drivers/usb/spec/rpi/platform.cc deleted file mode 100644 index 91b9fff4ed..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/rpi/platform.cc +++ /dev/null @@ -1,196 +0,0 @@ -/* - * \brief USB initialization for Raspberry Pi - * \author Norman Feske - * \date 2013-09-11 - */ - -/* - * Copyright (C) 2013-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -/* Genode includes */ -#include -#include -#include - - -/* emulation */ -#include -#include - -/* dwc-otg */ -#define new new_ -#include -#undef new - -using namespace Genode; - - -/************************************************ - ** Resource info passed to the dwc_otg driver ** - ************************************************/ - -enum { - DWC_BASE = 0x20980000, - DWC_SIZE = 0x20000, - DWC_IRQ = 9, -}; - - -/*************************************** - ** Supplement to lx_emul environment ** - ***************************************/ - -#if VERBOSE_LX_EMUL -#define TRACE lx_printf("\033[32m%s\033[0m called, not implemented\n", __PRETTY_FUNCTION__) -#else -#define TRACE -#endif - -#define DUMMY(retval, name) \ -extern "C" long name() { \ - lx_printf("\033[32m%s\033[0m called, not implemented, stop\n", #name); \ - bt(); \ - for (;;); \ - return retval; \ -} - -#define CHECKED_DUMMY(retval, name) \ -extern "C" long name() { \ - lx_printf("\033[32m%s\033[0m called, not implemented, ignored\n", #name); \ - bt(); \ - return retval; \ -} - -#define SILENT_DUMMY(retval, name) \ -extern "C" long name() { return retval; } - - -/********************* - ** linux/hardirq.h ** - *********************/ - -int in_irq() -{ - TRACE; - return 0; -} - - -/******************* - ** linux/delay.h ** - *******************/ - -unsigned long loops_per_jiffy = 1; - -/*********************************** - ** Dummies for unused PCD driver ** - ***********************************/ - -/* - * The PCD driver is used for driving the DWC-OTG device as gadget. The - * Raspberry Pi solely supports the use of the controller as host device. - * Hence, the PCD parts are not needed. - */ - -DUMMY(-1, dwc_otg_pcd_disconnect_us); -DUMMY(-1, dwc_otg_pcd_remote_wakeup); -DUMMY(-1, dwc_otg_pcd_get_rmwkup_enable); -DUMMY(-1, dwc_otg_pcd_initiate_srp); -DUMMY(-1, pcd_remove); -SILENT_DUMMY( 0, pcd_init); - - -/************************************************************************ - ** Prevent use of FIQ fix, need to resolve FIQ-related symbols anyway ** - ************************************************************************/ - -void local_fiq_disable() { } -void local_fiq_enable() { } -extern "C" void fiq_fsm_spin_lock(void *lock) { } -extern "C" void fiq_fsm_spin_unlock(void *lock) { } -int claim_fiq(struct fiq_handler *f) { return 0; } -void set_fiq_regs(struct pt_regs const *regs) { } -void set_fiq_handler(void *start, unsigned int length) { } -void enable_fiq() { } - -void __FIQ_Branch(unsigned long *regs) { TRACE; } - -extern "C" int fiq_fsm_too_late(struct fiq_state *st, int n) { TRACE; return 0; } -extern "C" void dwc_otg_fiq_nop(struct fiq_state *state) { TRACE; } -extern "C" void dwc_otg_fiq_fsm(struct fiq_state *state, int num_channels) { TRACE; } - -unsigned char _dwc_otg_fiq_stub, _dwc_otg_fiq_stub_end; - - -/*********************** - ** asm/dma_mapping.h ** - ***********************/ - -void *dma_to_virt(struct device *dev, dma_addr_t phys) -{ - return phys_to_virt(phys); -} - - -/******************* - ** linux/timer.h ** - *******************/ - -struct tvec_base { }; -struct tvec_base boot_tvec_bases; - - -/******************* - ** Init function ** - *******************/ - -extern "C" void module_dwc_otg_driver_init(); -extern "C" int module_usbnet_init(); -extern "C" int module_smsc95xx_driver_init(); - -void platform_hcd_init(Env &env, Services *services) -{ - static resource _dwc_otg_resource[] = - { - { DWC_BASE, DWC_BASE + DWC_SIZE - 1, "dwc_otg", IORESOURCE_MEM }, - { DWC_IRQ, DWC_IRQ, "dwc_otg-irq" /* name unused */, IORESOURCE_IRQ } - }; - - /* enable USB power */ - Platform::Connection platform(env); - platform.power_state(Platform::Session::POWER_USB_HCD, true); - - /* register network */ - if (services->nic) { - module_usbnet_init(); - module_smsc95xx_driver_init(); - } - - /* disable fiq optimization */ - fiq_enable = false; - fiq_fsm_enable = false; - - bool const verbose = false; - if (verbose) - g_dbg_lvl = DBG_HCD | DBG_CIL | DBG_HCD_URB; - - module_dwc_otg_driver_init(); - - /* setup host-controller platform device */ - platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0); - pdev->name = (char *)"dwc_otg"; - pdev->id = 0; - pdev->num_resources = sizeof(_dwc_otg_resource)/sizeof(resource); - pdev->resource = _dwc_otg_resource; - - /* needed for DMA buffer allocation. See 'hcd_buffer_alloc' in 'buffer.c' */ - static u64 dma_mask = ~(u64)0; - pdev->dev.dma_mask = &dma_mask; - pdev->dev.coherent_dma_mask = ~0; - - platform_device_register(pdev); -} diff --git a/repos/dde_linux/src/drivers/usb/spec/rpi/platform_session/client.h b/repos/dde_linux/src/drivers/usb/spec/rpi/platform_session/client.h deleted file mode 100644 index 8d56b8ee5a..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/rpi/platform_session/client.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/repos/dde_linux/src/drivers/usb/spec/rpi/platform_session/platform_session.h b/repos/dde_linux/src/drivers/usb/spec/rpi/platform_session/platform_session.h deleted file mode 100644 index 15d3b5bc29..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/rpi/platform_session/platform_session.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/repos/dde_linux/src/drivers/usb/spec/rpi/target.mk b/repos/dde_linux/src/drivers/usb/spec/rpi/target.mk deleted file mode 100644 index a6076cf237..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/rpi/target.mk +++ /dev/null @@ -1,49 +0,0 @@ -TARGET = rpi_usb_drv -REQUIRES = arm_v6 - -SRC_C += \ - usb/host/dwc_otg/dwc_otg/dwc_otg_adp.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_attr.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_cfi.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_cil.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_cil_intr.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_driver.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_hcd.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_hcd_ddma.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_hcd_intr.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_hcd_linux.c \ - usb/host/dwc_otg/dwc_otg/dwc_otg_hcd_queue.c \ - usb/host/dwc_otg/dwc_common_port/dwc_cc.c \ - usb/host/dwc_otg/dwc_common_port/dwc_common_linux.c \ - usb/host/dwc_otg/dwc_common_port/dwc_crypto.c \ - usb/host/dwc_otg/dwc_common_port/dwc_dh.c \ - usb/host/dwc_otg/dwc_common_port/dwc_mem.c \ - usb/host/dwc_otg/dwc_common_port/dwc_modpow.c \ - usb/host/dwc_otg/dwc_common_port/dwc_notifier.c - -SRC_C += net/usb/usbnet.c net/usb/smsc95xx.c - -include $(REP_DIR)/src/drivers/usb/spec/arm_v6/target.inc - -CC_OPT += -DDWC_LINUX -DPLATFORM_INTERFACE - -# needed for 'ehci-hcd.c', which we don't use on the rpi, but it is still -# part of the generic usb USB driver -CC_OPT += -DCONFIG_USB_EHCI_PCI=1 - -# for 'dwc_otg_hcd_linux.c' for enabling the FIQ, which we don't use anyway -CC_OPT += -DINTERRUPT_VC_USB=9 - -# for 'dwc_otg_driver.c' for preventing calls to set_irq_type -CC_OPT += -DIRQF_TRIGGER_LOW=1 - -INC_DIR += $(LX_CONTRIB_DIR)/drivers/usb/host/dwc_otg/dwc_common_port \ - $(LX_CONTRIB_DIR)/drivers/usb/host/dwc_otg/dwc_otg \ - $(call select_from_repositories,include/spec/rpi) -SRC_CC += platform.cc - -vpath platform.cc $(LIB_DIR)/spec/rpi -vpath %.c $(LX_CONTRIB_DIR)/drivers/net/usb - -# enable C++11 support -CC_CXX_OPT += -std=gnu++11 diff --git a/repos/dde_linux/src/drivers/usb/spec/x86/pci_driver.cc b/repos/dde_linux/src/drivers/usb/spec/x86/pci_driver.cc deleted file mode 100644 index 0c566164d3..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/x86/pci_driver.cc +++ /dev/null @@ -1,205 +0,0 @@ -/* - * \brief PCI device handling - * \author Sebastian Sumpf - * \date 2016-04-25 - */ - -/* - * Copyright (C) 2016-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -/* Genode includes */ -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - - -/** - * Quirks - */ -extern "C" void __pci_fixup_quirk_usb_early_handoff(void *data); - - -/** - * List of pci devices from platform driver - */ -class Pci_dev_list -{ - private: - - struct Element : public Lx_kit::List::Element - { - Platform::Device_capability cap; - - Element(Platform::Device_capability cap) : cap(cap) { } - }; - - Lx_kit::List _pci_caps; - - public: - - Pci_dev_list() - { - /* - * Obtain first device, the operation may exceed the session quota. - * So we use the 'with_upgrade' mechanism. - */ - Platform::Device_capability cap = - Lx::pci()->with_upgrade([&] () { - return Lx::pci()->first_device(); }); - - /* - * Iterate over the devices of the platform session. - */ - while (cap.valid()) { - - /* - * Keep PCI devices in natural bus order. Otherwise on a Lenovo - * ThinkCentre M57p, the system locks up when the UHCI - * controller BIOS handoff (disabling bit 4 in the LEGSUP - * register) for the controller with PCI BDF 00:1d:2 is - * attempted before the handoff for the controller with BDF - * 00:1a:0. - */ - _pci_caps.append(new (Lx::Malloc::mem()) Element(cap)); - - /* try next one. Upgrade session quota on demand.*/ - Lx::pci()->with_upgrade([&] () { - cap = Lx::pci()->next_device(cap); }); - } - } - - template - void for_each_pci_device(FUNC const &func) - { - for (Element *e = _pci_caps.first(); e; e = e->next()) - func(e->cap); - } -}; - - -Pci_dev_list *pci_dev_list() -{ - static Pci_dev_list _list; - return &_list; -} - - -extern "C" int pci_register_driver(struct pci_driver *driver) -{ - driver->driver.name = driver->name; - - pci_device_id const *id_table = driver->id_table; - if (!id_table) - return -ENODEV; - - using namespace Genode; - - bool found = false; - - auto lambda = [&] (Platform::Device_capability cap) { - - Platform::Device_client client(cap); - - /* request device ID from platform driver */ - unsigned const class_code = client.class_code(); - - /* look if we find the device ID in the driver's 'id_table' */ - pci_device_id const *matching_id = nullptr; - for (pci_device_id const *id = id_table; id->device; id++) { - - lx_log(DEBUG_PCI,"idclass: %x idclassm: %x devclass %x", id->class_, - id->class_mask, class_code); - - /* check for drivers that support any device for a given class */ - if (id->device != (unsigned)PCI_ANY_ID || !id->class_mask) - continue; - - if ((id->class_ & id->class_mask) == (class_code & id->class_mask)) { - matching_id = id; - break; - } - } - - /* skip device that is not handled by driver */ - if (!matching_id) - return false; - - /* create 'pci_dev' struct for matching device */ - Lx::Pci_dev *pci_dev = new (Lx::Malloc::mem()) Lx::Pci_dev(cap); - - /* enable ioremap to work */ - Lx::pci_dev_registry()->insert(pci_dev); - - /* register driver at the 'pci_dev' struct */ - pci_dev->dev.driver = &driver->driver; - - /* - * This quirk handles device handoff from BIOS, since the BIOS may still - * access the USB controller after bootup. For this the ext cap register of - * the PCI config space is checked - */ - if (Lx_kit::env().config_rom().xml().attribute_value("bios_handoff", true)) - __pci_fixup_quirk_usb_early_handoff(pci_dev); - - /* call probe function of the Linux driver */ - if (driver->probe(pci_dev, matching_id)) { - - /* if the probing failed, revert the creation of 'pci_dev' */ - pci_dev_put(pci_dev); - return false; - } - - found = true; - - /* multiple device support continue */ - return true; - }; - - pci_dev_list()->for_each_pci_device(lambda); - - return found ? 0 : -ENODEV; -} - - -/*********************** - ** linux/interrupt.h ** - ***********************/ - -int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, - const char *name, void *dev) -{ - for (Lx::Pci_dev *pci_dev = Lx::pci_dev_registry()->first(); pci_dev; pci_dev = pci_dev->next()) - if (pci_dev->irq == irq) { - Lx::Irq::irq().request_irq(pci_dev->client().irq(0), irq, handler, dev); - return 0; - } - - return -ENODEV; -} - - -/********************************* - ** Platform backend alloc init ** - *********************************/ - -void backend_alloc_init(Genode::Env &env, Genode::Ram_allocator &ram, - Genode::Allocator &alloc) -{ - Lx::pci_init(env, ram, alloc); -} diff --git a/repos/dde_linux/src/drivers/usb/spec/x86/platform.cc b/repos/dde_linux/src/drivers/usb/spec/x86/platform.cc deleted file mode 100644 index 4646c3da69..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/x86/platform.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * \brief X86 platform initialization - * \author Sebastian Sumpf - * \date 2013-05-17 - */ - -/* - * Copyright (C) 2013-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include - - -extern "C" void module_ax88179_178a_driver_init(); -extern "C" void module_cdc_driver_init(); -extern "C" void module_rndis_driver_init(); -extern "C" void module_usbnet_init(); -extern "C" void module_ehci_hcd_init(); -extern "C" void module_ehci_pci_init(); -extern "C" void module_ohci_hcd_mod_init(); -extern "C" void module_ohci_pci_init(); -extern "C" void module_uhci_hcd_init(); -extern "C" void module_xhci_hcd_init(); -extern "C" void module_xhci_pci_init(); - -void platform_hcd_init(Genode::Env &, Services *s) -{ - if (s->nic) { - module_usbnet_init(); - module_ax88179_178a_driver_init(); - module_cdc_driver_init(); - module_rndis_driver_init(); - } - - if (s->xhci) { - module_xhci_hcd_init(); - module_xhci_pci_init(); - } - - /* ehci_hcd should always be loaded before uhci_hcd and ohci_hcd, not after */ - if (s->ehci) { - module_ehci_hcd_init(); - module_ehci_pci_init(); - } - - if (s->ohci) { - module_ohci_hcd_mod_init(); - module_ohci_pci_init(); - } - - if (s->uhci) { - module_uhci_hcd_init(); - } -} diff --git a/repos/dde_linux/src/drivers/usb/spec/x86/target.inc b/repos/dde_linux/src/drivers/usb/spec/x86/target.inc deleted file mode 100644 index cdc405defc..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/x86/target.inc +++ /dev/null @@ -1,27 +0,0 @@ -SRC_C += $(addprefix usb/host/,pci-quirks.c uhci-hcd.c ehci-pci.c ohci-hcd.c ohci-pci.c) -SRC_C += usb/core/hcd-pci.c - -# -# USB netwpork support -# -SRC_C += $(addprefix net/usb/, usbnet.c ax88179_178a.c cdc_ether.c rndis_host.c) - -# XHCI -SRC_C += usb/host/xhci-pci.c - -# PCI -SRC_CC += pci_driver.cc platform.cc - -# lx_kit -SRC_CC += pci.cc mapped_io_mem_range.cc - - -include $(REP_DIR)/src/drivers/usb/xhci.inc -include $(REP_DIR)/src/drivers/usb/target.inc - -CC_OPT += -DCONFIG_PCI -DCONFIG_USB_EHCI_PCI=1 -DCONFIG_USB_XHCI_HCD=1 - -vpath platform.cc $(LIB_DIR)/spec/x86 -vpath pci_driver.cc $(LIB_DIR)/spec/x86 - -# vi:set ft=make : diff --git a/repos/dde_linux/src/drivers/usb/spec/x86_32/target.mk b/repos/dde_linux/src/drivers/usb/spec/x86_32/target.mk deleted file mode 100644 index 1ed3c7a090..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/x86_32/target.mk +++ /dev/null @@ -1,7 +0,0 @@ -TARGET = usb_drv -REQUIRES = x86_32 - -INC_DIR += $(LIB_INC_DIR)/spec/x86_32 $(LIB_INC_DIR)/spec/x86 -INC_DIR += $(REP_DIR)/src/include/spec/x86_32 - -include $(REP_DIR)/src/drivers/usb/spec/x86/target.inc diff --git a/repos/dde_linux/src/drivers/usb/spec/x86_64/target.mk b/repos/dde_linux/src/drivers/usb/spec/x86_64/target.mk deleted file mode 100644 index c0f00197f4..0000000000 --- a/repos/dde_linux/src/drivers/usb/spec/x86_64/target.mk +++ /dev/null @@ -1,7 +0,0 @@ -TARGET = usb_drv -REQUIRES = x86_64 - -INC_DIR += $(LIB_INC_DIR)/spec/x86_64 $(LIB_INC_DIR)/spec/x86 -INC_DIR += $(REP_DIR)/src/include/spec/x86_64 - -include $(REP_DIR)/src/drivers/usb/spec/x86/target.inc diff --git a/repos/dde_linux/src/drivers/usb/storage/scsi.c b/repos/dde_linux/src/drivers/usb/storage/scsi.c deleted file mode 100644 index a18bc75ef9..0000000000 --- a/repos/dde_linux/src/drivers/usb/storage/scsi.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * \brief SCSI support emulation - * \author Christian Helmuth - * \author Sebastian Sumpf - * \date 2009-10-29 - * - * XXX NOTES XXX - * - * struct scsi_host_template - * - * struct scsi_host - * - * host_lock used by scsi_unlock, scsi_lock - * max_id used by usb_stor_report_device_reset - * - * struct scsi_cmnd - * - * functions - * - * scsi_add_host - * scsi_host_alloc - * scsi_host_get - * scsi_host_put - * scsi_remove_host - * scsi_report_bus_reset - * scsi_report_device_reset - * scsi_scan_host - */ - -/* - * Copyright (C) 2009-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include - -#include - -#define DEBUG_SCSI 0 - -/*************** - ** SCSI host ** - ***************/ - -struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *t, int priv_size) -{ - lx_log(DEBUG_SCSI, "t=%p, priv_size=%d", t, priv_size); - - static int free = 1; - - /* XXX we not some extra space for hostdata[] */ - static char buffer[4096] __attribute__((aligned(4096))); - static struct Scsi_Host *host = (struct Scsi_Host *)buffer; - - /* FIXME we support only one host for now */ - if (!free) return 0; - free = 0; - - host->host_lock = &host->default_lock; - spin_lock_init(host->host_lock); - - host->host_no = 13; - host->max_id = 8; - host->hostt = t; - - return host; -} - - -static struct page *_page(struct scsi_cmnd *cmnd) -{ - return (struct page *)cmnd->sdb.table.sgl->page_link; -} - - -void scsi_alloc_buffer(size_t size, struct scsi_cmnd *cmnd) -{ - scsi_setup_buffer(cmnd, size, 0, 0); - struct scatterlist *sgl = cmnd->sdb.table.sgl; - struct page *page = _page(cmnd); - page->virt = kmalloc(size, GFP_NOIO); - page->phys = dma_map_single_attrs(0, page->virt, 0, 0, 0); - sgl->dma_address = page->phys; -} - - -void scsi_setup_buffer(struct scsi_cmnd *cmnd, size_t size, void *virt, dma_addr_t addr) -{ - cmnd->sdb.table.nents = 1; - cmnd->sdb.length = size; - - struct scatterlist *sgl = cmnd->sdb.table.sgl; - - struct page *page = _page(cmnd); - page->virt = virt; - page->phys = addr; - - sgl->page_link = (unsigned long)page; - sgl->offset = 0; - sgl->length = size; - sgl->dma_address = addr; - sgl->last = 1; -} - - -void scsi_free_buffer(struct scsi_cmnd *cmnd) -{ - struct page *page = _page(cmnd); - if (page) - kfree(page->virt); -} - - -void *scsi_buffer_data(struct scsi_cmnd *cmnd) -{ - return _page(cmnd)->virt; -} - - -struct scsi_cmnd *_scsi_alloc_command() -{ - struct scsi_cmnd *cmnd = (struct scsi_cmnd *)kmalloc(sizeof(struct scsi_cmnd), GFP_KERNEL); - cmnd->sdb.table.sgl = (struct scatterlist *)kmalloc(sizeof(struct scatterlist), GFP_KERNEL); - cmnd->cmnd = kzalloc(MAX_COMMAND_SIZE, 0); - cmnd->sdb.table.sgl->page_link = (unsigned long) kzalloc(sizeof(struct page), 0); - cmnd->sense_buffer = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); - return cmnd; -} - - -void _scsi_free_command(struct scsi_cmnd *cmnd) -{ - kfree((void *)cmnd->sdb.table.sgl->page_link); - kfree(cmnd->sdb.table.sgl); - kfree(cmnd->sense_buffer); - kfree(cmnd->cmnd); - kfree(cmnd); -} - - -static void inquiry_done(struct scsi_cmnd *cmnd) -{ - char *data = (char *)scsi_buffer_data(cmnd); - lx_printf("Vendor id: %c%c%c%c%c%c%c%c Product id: %s\n", - data[8], data[9], data[10], data[11], data[12], - data[13], data[14], data[15], &data[16]); - complete(cmnd->back); -} - - -static void scsi_done(struct scsi_cmnd *cmd) -{ - complete(cmd->back); -} - - -void scsi_scan_host(struct Scsi_Host *host) -{ - struct scsi_cmnd *cmnd; - struct scsi_device *sdev; - struct scsi_target *target; - struct completion compl; - void *result; - - init_completion(&compl); - - sdev = (struct scsi_device *)kmalloc(sizeof(struct scsi_device), GFP_KERNEL); - target = (struct scsi_target *)kmalloc(sizeof(struct scsi_target), GFP_KERNEL); - - cmnd = _scsi_alloc_command(); - - /* init device */ - sdev->sdev_target = target; - sdev->host = host; - sdev->id = 0; - sdev->lun = 0; - host->hostt->slave_alloc(sdev); - host->hostt->slave_configure(sdev); - - /* inquiry (36 bytes for usb) */ - scsi_alloc_buffer(sdev->inquiry_len, cmnd); - cmnd->cmnd[0] = INQUIRY; - cmnd->cmnd[4] = sdev->inquiry_len; - cmnd->device = sdev; - cmnd->cmd_len = 6; - cmnd->sc_data_direction = DMA_FROM_DEVICE; - - cmnd->back = &compl; - cmnd->scsi_done = inquiry_done; - - host->hostt->queuecommand(host, cmnd); - wait_for_completion(&compl); - - /* if PQ and PDT are zero we have a direct access block device conntected */ - result = scsi_buffer_data(cmnd); - if (!((char*)result)[0]) - scsi_add_device(sdev); - else { - kfree(sdev); - kfree(target); - } - - scsi_free_buffer(cmnd); - _scsi_free_command(cmnd); -} - - -/********************** - ** scsi/scsi_cmnd.h ** - **********************/ - -unsigned scsi_bufflen(struct scsi_cmnd *cmnd) { return cmnd->sdb.length; } -struct scatterlist *scsi_sglist(struct scsi_cmnd *cmnd) { return cmnd->sdb.table.sgl; } -unsigned scsi_sg_count(struct scsi_cmnd *cmnd) { return cmnd->sdb.table.nents; } - - -/******************** - ** scsi/scsi_eh.h ** - *******************/ - -void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, - struct scsi_eh_save *ses, unsigned char *cmnd, - int cmnd_size, unsigned sense_bytes) -{ - ses->cmd_len = scmd->cmd_len; -} - - -void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, - struct scsi_eh_save *ses) -{ - scmd->cmd_len = ses->cmd_len; -} diff --git a/repos/dde_linux/src/drivers/usb/storage/storage.cc b/repos/dde_linux/src/drivers/usb/storage/storage.cc deleted file mode 100644 index 947fe97efb..0000000000 --- a/repos/dde_linux/src/drivers/usb/storage/storage.cc +++ /dev/null @@ -1,246 +0,0 @@ -/* - * \brief USB storage glue - * \author Sebastian Sumpf - * \date 2012-05-06 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "signal.h" - -static Signal_helper *_signal = 0; - -class Storage_device : public Genode::List::Element, - public Block::Driver -{ - private: - - Genode::size_t _block_size; - Block::sector_t _block_count; - struct scsi_device *_sdev; - - static void _sync_done(struct scsi_cmnd *cmnd) { - complete((struct completion *)cmnd->back); } - - static void _async_done(struct scsi_cmnd *cmnd); - - void _capacity() - { - struct completion comp; - - struct scsi_cmnd *cmnd = _scsi_alloc_command(); - - /* alloc data for command */ - scsi_alloc_buffer(8, cmnd); - - cmnd->cmnd[0] = READ_CAPACITY; - cmnd->cmd_len = 10; - cmnd->device = _sdev; - cmnd->sc_data_direction = DMA_FROM_DEVICE; - - init_completion(&comp); - cmnd->back = ∁ - cmnd->scsi_done = _sync_done; - - _sdev->host->hostt->queuecommand(_sdev->host, cmnd); - wait_for_completion(&comp); - - Genode::uint32_t *data = (Genode::uint32_t *)scsi_buffer_data(cmnd); - _block_count = host_to_big_endian(data[0]); - _block_size = host_to_big_endian(data[1]); - - /* if device returns the highest block number */ - if (!_sdev->fix_capacity) - _block_count++; - - if (verbose) - Genode::log("block size: ", _block_size, " block count", _block_count); - - scsi_free_buffer(cmnd); - _scsi_free_command(cmnd); - } - - void _io(Block::sector_t block_nr, Genode::size_t block_count, - Block::Packet_descriptor packet, - Genode::addr_t phys, bool read) - { - if (block_nr > _block_count) - throw Io_error(); - - if (verbose) - log("PACKET: phys: ", Genode::Hex(phys), " block: ", block_nr, "count: ", block_count, - read ? " read" : " write"); - - /* check if we can call queuecommand */ - struct us_data *us = (struct us_data *) _sdev->host->hostdata; - if (us->srb != NULL) - throw Request_congestion(); - - struct scsi_cmnd *cmnd = _scsi_alloc_command(); - - cmnd->cmnd[0] = read ? READ_10 : WRITE_10; - cmnd->cmd_len = 10; - cmnd->device = _sdev; - cmnd->sc_data_direction = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE; - cmnd->scsi_done = _async_done; - - Block::Packet_descriptor *p = new (Lx::Malloc::mem()) Block::Packet_descriptor(); - *p = packet; - cmnd->packet = (void *)p; - - Genode::uint32_t be_block_nr = host_to_big_endian(block_nr); - memcpy(&cmnd->cmnd[2], &be_block_nr, 4); - - /* transfer one block */ - Genode::uint16_t be_block_count = host_to_big_endian(block_count); - memcpy(&cmnd->cmnd[7], &be_block_count, 2); - - /* setup command */ - scsi_setup_buffer(cmnd, block_count * _block_size, (void *)0, phys); - - /* - * Required by 'last_sector_hacks' in 'drivers/usb/storage/transprot.c - */ - struct request req; - req.rq_disk = 0; - cmnd->request = &req; - - /* send command to host driver */ - _sdev->host->hostt->queuecommand(_sdev->host, cmnd); - - /* schedule next task if we come from EP */ - if (Lx::scheduler().active() == false) - Lx::scheduler().schedule(); - } - - public: - - Storage_device(Genode::Ram_allocator &ram, struct scsi_device *sdev) - : Block::Driver(ram), _sdev(sdev) - { - /* read device capacity */ - _capacity(); - } - - Block::Session::Info info() const override - { - return { .block_size = _block_size, - .block_count = _block_count, - .align_log2 = Genode::log2(_block_size), - .writeable = true }; - } - - void read_dma(Block::sector_t block_number, - Genode::size_t block_count, - Genode::addr_t phys, - Block::Packet_descriptor &packet) { - _io(block_number, block_count, packet, phys, true); } - - void write_dma(Block::sector_t block_number, - Genode::size_t block_count, - Genode::addr_t phys, - Block::Packet_descriptor &packet) { - _io(block_number, block_count, packet, phys, false); } - - bool dma_enabled() { return true; } - - Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t size) { - return Lx::backend_alloc(size, Genode::UNCACHED); } - - void free_dma_buffer(Genode::Ram_dataspace_capability cap) { - return Lx::backend_free(cap); } -}; - - -void Storage::init(Genode::Env &env) { - _signal = new (Lx::Malloc::mem()) Signal_helper(env); } - - -struct Factory : Block::Driver_factory -{ - Storage_device device; - - Factory(Genode::Ram_allocator &ram, struct scsi_device *sdev) - : device(ram, sdev) {} - - Block::Driver *create() { return &device; } - void destroy(Block::Driver *driver) { } -}; - - -static Storage_device *device = nullptr; -static work_struct delayed; - - -extern "C" void ack_packet(work_struct *work) -{ - Block::Packet_descriptor *packet = - (Block::Packet_descriptor *)(work->data); - - if (verbose) - Genode::log("ACK packet for block: ", packet->block_number()); - - device->ack_packet(*packet); - Genode::destroy(Lx::Malloc::mem(), packet); -} - - -void scsi_add_device(struct scsi_device *sdev) -{ - using namespace Genode; - static bool announce = false; - - static struct Factory factory(_signal->ram(), sdev); - device = &factory.device; - - /* - * XXX move to 'main' - */ - if (!announce) { - enum { WRITEABLE = true }; - - PREPARE_WORK(&delayed, ack_packet); - static Block::Root root(_signal->ep(), Lx::Malloc::mem(), - _signal->rm(), factory, WRITEABLE); - _signal->parent().announce(_signal->ep().rpc_ep().manage(&root)); - announce = true; - } -} - - -void Storage_device::_async_done(struct scsi_cmnd *cmnd) -{ - /* - * Schedule packet ack, because we are called here in USB storage thread - * context, the from code that will clear the command queue later, so we - * cannot send the next packet from here - */ - delayed.data = cmnd->packet; - schedule_work(&delayed); - - scsi_free_buffer(cmnd); - _scsi_free_command(cmnd); - -} diff --git a/repos/dde_linux/src/drivers/usb/target.inc b/repos/dde_linux/src/drivers/usb/target.inc deleted file mode 100644 index 93dfb357b6..0000000000 --- a/repos/dde_linux/src/drivers/usb/target.inc +++ /dev/null @@ -1,100 +0,0 @@ -SRC_CC += main.cc -LIBS = base nic_driver - -CC_CXX_WARN_STRICT = - -LIB_DIR = $(REP_DIR)/src/drivers/usb -LIB_INC_DIR = $(LIB_DIR)/include - -LIBS += usb_include lx_kit_setjmp -SRC_CC += lx_emul.cc storage.cc \ - input_component.cc evdev.cc nic.cc raw.cc -SRC_C += dummies.c scsi.c raw_driver.c - -LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/lib/usb -DRIVERS_DIR := $(LX_CONTRIB_DIR)/drivers -USB_DIR := $(DRIVERS_DIR)/usb - -# -# The order of include-search directories is important, we need to look into -# 'contrib' before falling back to our custom 'lx_emul.h' header. -# -INC_DIR += $(PRG_DIR) -INC_DIR += $(LIB_INC_DIR) $(REP_DIR)/src/include -INC_DIR += $(LX_CONTRIB_DIR)/include $(LX_CONTRIB_DIR)/include/uapi $(LX_CONTRIB_DIR) - -CC_OPT += -U__linux__ -D__KERNEL__ -CC_OPT += -DCONFIG_USB_DEVICEFS -DCONFIG_HOTPLUG -DDEBUG -DCONFIG_USB_PHY=1 \ - -DCONFIG_GENERIC_PHY=0 -DCONFIG_USB_OTG_WHITELIST=0 \ - -DCONFIG_USB_OTG=0 -DCONFIG_USB_NET_RNDIS_HOST=1 - -CC_WARN = -Wall -Wno-unused-variable -Wno-uninitialized \ - -Wno-unused-function -Wno-overflow - -CC_C_OPT += -std=gnu89 -Wno-unused-but-set-variable -Wno-pointer-sign -Wno-unused-label -CC_C_OPT += -include $(LIB_INC_DIR)/lx_emul.h - -CC_CXX_OPT += -fpermissive - -# -# Suffix of global 'module_init' function -# -MOD_SUFFIX = -CC_OPT += -DMOD_SUFFIX=$(MOD_SUFFIX) - -# lx_kit -SRC_CC += printf.cc bug.cc work.cc timer.cc scheduler.cc irq.cc malloc.cc env.cc - -# common lib -SRC_C += lib/ctype.c -SRC_C += lib/int_sqrt.c - -# USB core -SRC_C += $(addprefix usb/core/, buffer.c config.c devices.c driver.c endpoint.c file.c \ - generic.c hcd.c hub.c message.c notify.c port.c quirks.c\ - urb.c usb.c) - -# USB host-controller driver -SRC_C += $(addprefix usb/host/, ehci-hcd.c) - -# common -SRC_C += usb/common/common.c - -# USB hid -SRC_C += $(addprefix hid/usbhid/, hid-core.c hid-quirks.c) -SRC_C += $(addprefix hid/, hid-core.c hid-generic.c hid-input.c \ - hid-cherry.c hid-microsoft.c hid-multitouch.c \ - wacom_sys.c wacom_wac.c) -SRC_C += $(addprefix input/, evdev.c input.c input-mt.c) - -# USB storage -SRC_C += $(addprefix usb/storage/,scsiglue.c protocol.c transport.c usb.c \ - initializers.c option_ms.c sierra_ms.c usual-tables.c) - -# SCSI -SRC_C += $(addprefix scsi/,scsi.c constants.c) - -#SRC_CC = storage.cc -#SRC_C = - -# -# Add suffix, since there are two hid-core.c with the same module init function -# -hid/hid-core.o: MOD_SUFFIX="_core" - -vpath %.c $(DRIVERS_DIR) -vpath %.c $(LIB_DIR) -vpath %.cc $(LIB_DIR) -vpath %.cc $(LIB_DIR)/signal -vpath %.c $(LIB_DIR)/input -vpath %.cc $(LIB_DIR)/input -vpath %.cc $(LIB_DIR)/storage -vpath %.c $(LIB_DIR)/storage -vpath %.cc $(LIB_DIR)/nic -vpath %.cc $(LIB_DIR)/raw -vpath %.c $(LIB_DIR)/raw -vpath lib/int_sqrt.c $(LX_CONTRIB_DIR) -vpath lib/ctype.c $(LX_CONTRIB_DIR) -vpath %.cc $(REP_DIR)/src/lx_kit - -# vi: set ft=make : diff --git a/repos/dde_linux/src/drivers/usb/test.cc b/repos/dde_linux/src/drivers/usb/test.cc deleted file mode 100644 index c324842b18..0000000000 --- a/repos/dde_linux/src/drivers/usb/test.cc +++ /dev/null @@ -1,44 +0,0 @@ -/* - * \brief Test functions - * \author Sebastian Sumpf - * \date 2012-08-02 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#if 0 - -void tx_test() { - char *data = (char *)skb->data; - if (data[0x2a] == (char)0xaa && data[0x2b] == (char)0xbb) { - Genode::log("Got server signal"); - static char data[1066]; - static char header[] = { - 0x00, 0x1c, 0x25, 0x9e, 0x92, 0x4a, 0x2e, 0x60, 0x90, 0x0c, 0x4e, 0x01, 0x08, 0x00, 0x45, 0x00, - 0x04, 0x1c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11, 0x22, 0x88, 0x0a, 0x00, 0x00, 0x3b, 0x0a, 0x00, - 0x00, 0x0f, 0x89, 0xc5, 0x04, 0xd2, 0x04, 0x08, 0x54, 0xfd}; - Genode::memset(data, 0, 1065); - memcpy(data, header, sizeof(header)); - while (1) { - sk_buff *skb = alloc_skb(1066 + HEAD_ROOM, 0); - if (!skb) { - Service_handler::s()->check_signal(); - continue; - } - skb->len = 1066; - skb->data += HEAD_ROOM; - - memcpy(skb->data, data, 1066); - - _nic->_ndev->netdev_ops->ndo_start_xmit(skb, _nic->_ndev); - dev_kfree_skb(skb); - } - } -} - -#endif diff --git a/repos/dde_linux/src/drivers/usb/xhci.inc b/repos/dde_linux/src/drivers/usb/xhci.inc deleted file mode 100644 index 493245a2ee..0000000000 --- a/repos/dde_linux/src/drivers/usb/xhci.inc +++ /dev/null @@ -1,6 +0,0 @@ -# -# Generic XHCI files -# -SRC_C += $(addprefix usb/host/, xhci-dbg.c xhci-hub.c xhci-mem.c xhci-ring.c xhci.c) - -# vi:set ft=make : diff --git a/repos/dde_linux/src/drivers/usb_host/README b/repos/dde_linux/src/drivers/usb_host/README index fa734606f1..94270f443b 100644 --- a/repos/dde_linux/src/drivers/usb_host/README +++ b/repos/dde_linux/src/drivers/usb_host/README @@ -1,14 +1,15 @@ USB host controller driver ########################## -Allows access to USB devices via the 'Usb' session interface. - -Configuration snippet: +The driver will start all USB controller types a platform offers +(USB 1.0/2.0/3.0). Controllers can be disabled as attribute in the config node +of the driver. Supported attributes are: 'uhci', 'ohci', 'ehci', and 'xhci'. ! +! ! ! -! +! ! ! ! @@ -28,14 +29,12 @@ USB device. Only devices that have a valid policy configured at the USB driver can be accessed by a client. The following configuration allows 'comp1' to access the device 'usb-1-6': -! +! ! ! -! -! -! -! -! +! +! +! ! ! diff --git a/tool/autopilot.list b/tool/autopilot.list index 6e0f37f47e..fd16606e60 100644 --- a/tool/autopilot.list +++ b/tool/autopilot.list @@ -68,7 +68,6 @@ timeout timeout_smp timer_accuracy tz_vmm -usb_hid usb_hid_raw vbox5_genode_usb_hid_raw vbox5_ubuntu_16_04_32