1 /* 2 * Copyright 2009, Colin Günther, coling@gmx.de. All Rights Reserved. 3 * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All Rights Reserved. 4 * Copyright 2007, Hugo Santos. All Rights Reserved. 5 * Copyright 2004, Marcus Overhagen. All Rights Reserved. 6 * Distributed under the terms of the MIT License. 7 */ 8 #ifndef DEVICE_H 9 #define DEVICE_H 10 11 12 #include <stdint.h> 13 #include <stdio.h> 14 15 #include <KernelExport.h> 16 #include <drivers/PCI.h> 17 18 #include <util/list.h> 19 20 #include <compat/sys/kernel.h> 21 #include <compat/net/if.h> 22 23 #include "shared.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 struct root_device_softc { 30 enum { 31 BUS_INVALID = 0, 32 BUS_pci, 33 BUS_uhub, 34 } bus; 35 36 struct pci_info pci_info; 37 bool is_msi; 38 bool is_msix; 39 40 struct freebsd_usb_device* usb_dev; 41 }; 42 43 enum { 44 DEVICE_OPEN = 1 << 0, 45 DEVICE_CLOSED = 1 << 1, 46 DEVICE_NON_BLOCK = 1 << 2, 47 DEVICE_DESC_ALLOCED = 1 << 3, 48 DEVICE_ATTACHED = 1 << 4, 49 DEVICE_SOFTC_SET = 1 << 5 // Set through device_set_softc(). 50 }; 51 52 53 extern struct net_buffer_module_info *gBufferModule; 54 extern pci_module_info *gPci; 55 56 57 static inline void 58 __unimplemented(const char *method) 59 { 60 char msg[128]; 61 snprintf(msg, sizeof(msg), "fbsd compat, unimplemented: %s", method); 62 panic(msg); 63 } 64 65 #define UNIMPLEMENTED() __unimplemented(__FUNCTION__) 66 67 status_t init_mbufs(void); 68 void uninit_mbufs(void); 69 70 status_t init_mutexes(void); 71 void uninit_mutexes(void); 72 73 status_t init_taskqueues(void); 74 void uninit_taskqueues(void); 75 76 status_t init_hard_clock(void); 77 void uninit_hard_clock(void); 78 79 status_t init_callout(void); 80 void uninit_callout(void); 81 82 status_t init_pci(); 83 void uninit_pci(); 84 85 status_t init_usb(); 86 void uninit_usb(); 87 88 status_t get_next_usb_device(uint32* cookie, struct freebsd_usb_device* result); 89 status_t get_usb_device_attach_arg(struct freebsd_usb_device* device, struct usb_attach_arg* uaa); 90 91 device_t find_root_device(int); 92 pci_info* get_device_pci_info(device_t dev); 93 94 void driver_printf(const char *format, ...) 95 __attribute__ ((format (__printf__, 1, 2))); 96 int driver_vprintf(const char *format, va_list vl); 97 98 void device_sprintf_name(device_t dev, const char *format, ...) 99 __attribute__ ((format (__printf__, 2, 3))); 100 101 void ifq_init(struct ifqueue *, const char *); 102 void ifq_uninit(struct ifqueue *); 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif /* DEVICE_H */ 109