BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / drivers / network / pegasus / driver.h
bloba0e916aef6d9d76d7a72b4408b935a3725eae133
1 /*
2 * Pegasus BeOS Driver
3 *
4 * Copyright 2006, Haiku, Inc. All Rights Reserved.
5 * Distributed under the terms of the MIT License.
7 * Authors:
8 * Jérôme Duval
9 */
10 #ifndef _DEV_PEGASUS_H_
11 #define _DEV_PEGASUS_H_
13 #include <Drivers.h>
14 #include <OS.h>
15 #include <SupportDefs.h>
16 #include <USB3.h>
18 #include "ether_driver.h"
20 #include "ByteOrder.h"
22 // compat
23 #define u_uint8_t uint8
24 #define u_uint16_t uint16
25 #define u_int8_t int8
26 #define u_int16_t int16
27 #define DELAY snooze
29 #include "if_auereg.h"
31 #define VERSION "Version 0, Copyright (c) 2006 Jérôme Duval, compiled on " ## __DATE__ ## " " ## __TIME__
32 #define DRIVER_NAME "pegasus"
34 #define MY_ID "\033[34m" DRIVER_NAME ":\033[m "
35 #define MY_ERR "\033[31merror:\033[m "
36 #define MY_WARN "\033[31mwarning:\033[m "
38 //#define DEBUG 1
39 #if DEBUG
40 #define DPRINTF_INFO(x...) dprintf(MY_ID x)
41 #define DPRINTF_ERR(x...) dprintf(MY_ID x)
42 #else
43 #define DPRINTF_INFO(x...)
44 #define DPRINTF_ERR(x...) dprintf(MY_ID x)
45 #endif
47 #define ASSERT(x) \
48 ((x) ? 0 : dprintf (MY_ID "assertion failed at " __FILE__ ", line %d\n", __LINE__))
50 #define NUM_CARDS 3
51 #define DEVNAME 32
53 #define DEFAULT_CONFIGURATION 0
55 #define ENET_HEADER_SIZE 14
56 #define ETHER_ADDRESS_LENGTH 6
57 #define MAX_FRAME_SIZE 1536
58 #define ETHER_TRANSMIT_TIMEOUT ((bigtime_t)5000000)
59 /* five seconds */
62 * Various supported device vendors/products.
64 struct aue_type {
65 struct usb_devno {
66 uint16 vendor;
67 uint16 product;
68 } aue_dev;
69 uint16 aue_flags;
70 #define LSYS 0x0001 /* use Linksys reset */
71 #define PNA 0x0002 /* has Home PNA */
72 #define PII 0x0004 /* Pegasus II chip */
77 * Devices
80 typedef struct _pegasus_dev {
81 /* list structure */
82 struct _pegasus_dev *next;
84 uint32 cookieMagic;
86 /* maintain device */
87 sem_id sem_lock;
89 char name[DEVNAME]; /* used for resources */
90 int type;
91 usb_device dev;
92 uint16 aue_vendor;
93 uint16 aue_product;
95 uint16 ifno;
97 int open;
98 struct driver_cookie *open_fds;
99 volatile bool aue_dying;
100 int number;
101 uint flags;
103 int aue_unit;
104 uint16 aue_flags;
106 volatile bool nonblocking;
108 uint32 maxframesize; // 14 bytes header + MTU
109 uint8 macaddr[6];
111 usb_pipe pipe_in; /**/
112 usb_pipe pipe_out; /**/
113 usb_pipe pipe_intr; /**/
115 uint16 phy;
116 bool link;
118 // receive data
120 sem_id rx_sem;
121 sem_id rx_sem_cb;
122 char rx_buffer[MAX_FRAME_SIZE];
123 status_t rx_status;
124 size_t rx_actual_length;
126 // transmit data
128 sem_id tx_sem;
129 sem_id tx_sem_cb;
130 char tx_buffer[MAX_FRAME_SIZE];
131 status_t tx_status;
132 size_t tx_actual_length;
134 } pegasus_dev;
136 #define PEGASUS_COOKIE_MAGIC 'pega'
139 /* driver.c */
141 extern usb_module_info *usb;
143 pegasus_dev *create_device(const usb_device dev, const usb_interface_info *ii, uint16 ifno);
144 void remove_device(pegasus_dev *device);
146 /* devlist.c */
148 extern sem_id gDeviceListLock;
149 extern bool gDeviceListChanged;
151 void add_device_info(pegasus_dev *device);
152 void remove_device_info(pegasus_dev *device);
153 pegasus_dev *search_device_info(const char *name);
155 extern char **gDeviceNames;
157 void alloc_device_names(void);
158 void free_device_names(void);
159 void rebuild_device_names(void);
161 /* if_aue.c */
162 void aue_attach(pegasus_dev *sc);
163 void aue_init(pegasus_dev *sc);
164 void aue_uninit(pegasus_dev *sc);
166 #endif /* _DEV_PEGASUS_H_ */