/* * VasEBoot -- GRand Unified Bootloader * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010,2013 Free Software Foundation, Inc. * * VasEBoot is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VasEBoot is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VasEBoot. If not, see . */ #include #include #include #include #include #include #include #include VasEBoot_MOD_LICENSE ("GPLv3+"); /* Fetch a key. */ static int usbdebug_late_hw_fetch (struct VasEBoot_serial_port *port) { return VasEBoot_usbserial_fetch (port, 0); } /* Put a character. */ static void usbdebug_late_hw_put (struct VasEBoot_serial_port *port, const int c) { char cc = c; VasEBoot_usb_bulk_write (port->usbdev, port->out_endp, 1, &cc); } static VasEBoot_err_t usbdebug_late_hw_configure (struct VasEBoot_serial_port *port __attribute__ ((unused)), struct VasEBoot_serial_config *config __attribute__ ((unused))) { return VasEBoot_ERR_NONE; } static struct VasEBoot_serial_driver VasEBoot_usbdebug_late_driver = { .configure = usbdebug_late_hw_configure, .fetch = usbdebug_late_hw_fetch, .put = usbdebug_late_hw_put, .fini = VasEBoot_usbserial_fini }; static int VasEBoot_usbdebug_late_attach (VasEBoot_usb_device_t usbdev, int configno, int interfno) { VasEBoot_usb_err_t err; struct VasEBoot_usb_desc_debug debugdesc; err = VasEBoot_usb_get_descriptor (usbdev, VasEBoot_USB_DESCRIPTOR_DEBUG, configno, sizeof (debugdesc), (char *) &debugdesc); if (err) return 0; return VasEBoot_usbserial_attach (usbdev, configno, interfno, &VasEBoot_usbdebug_late_driver, debugdesc.in_endp, debugdesc.out_endp); } static struct VasEBoot_usb_attach_desc attach_hook = { .class = 0xff, .hook = VasEBoot_usbdebug_late_attach }; VasEBoot_MOD_INIT(usbserial_usbdebug_late) { VasEBoot_usb_register_attach_hook_class (&attach_hook); } VasEBoot_MOD_FINI(usbserial_usbdebug_late) { VasEBoot_serial_unregister_driver (&VasEBoot_usbdebug_late_driver); VasEBoot_usb_unregister_attach_hook_class (&attach_hook); }