Переглянути джерело

Tie into new boot device framework.

tags/v0.9.3
Michael Brown 19 роки тому
джерело
коміт
5c31682674
1 змінених файлів з 50 додано та 17 видалено
  1. 50
    17
      src/include/nic.h

+ 50
- 17
src/include/nic.h Переглянути файл

@@ -8,7 +8,9 @@
8 8
 #ifndef	NIC_H
9 9
 #define NIC_H
10 10
 
11
-#include "dev.h"
11
+/* to get global "dev" */
12
+struct dev;
13
+#include "main.h"
12 14
 
13 15
 typedef enum {
14 16
 	DISABLE = 0,
@@ -20,15 +22,9 @@ typedef enum {
20 22
  *	Structure returned from eth_probe and passed to other driver
21 23
  *	functions.
22 24
  */
23
-struct nic
24
-{
25
-	struct dev	dev;  /* This must come first */
26
-	int		(*poll)P((struct nic *, int retrieve));
27
-	void		(*transmit)P((struct nic *, const char *d,
28
-				unsigned int t, unsigned int s, const char *p));
29
-	void		(*irq)P((struct nic *, irq_action_t));
25
+struct nic {
26
+	struct nic_operations *nic_op;
30 27
 	int		flags;	/* driver specific flags */
31
-	struct rom_info	*rom_info;	/* -> rom_info from main */
32 28
 	unsigned char	*node_addr;
33 29
 	unsigned char	*packet;
34 30
 	unsigned int	packetlen;
@@ -37,13 +33,50 @@ struct nic
37 33
 	void		*priv_data;	/* driver can hang private data here */
38 34
 };
39 35
 
36
+struct nic_operations {
37
+	int ( *connect ) ( struct nic * );
38
+	int ( *poll ) ( struct nic *, int retrieve );
39
+	void ( *transmit ) ( struct nic *, const char *,
40
+			     unsigned int, unsigned int, const char * );
41
+	void ( *irq ) ( struct nic *, irq_action_t );
42
+	void ( *disable ) ( struct nic * );
43
+};
44
+
45
+/*
46
+ * Function prototypes
47
+ *
48
+ */
49
+extern struct nic * nic_device ( struct dev * dev );
50
+
51
+/*
52
+ * Functions that implicitly operate on the current boot device
53
+ *
54
+ * "nic" always points to &dev.nic
55
+ */
56
+
57
+extern struct nic *nic;
58
+
59
+static inline int eth_connect ( void ) {
60
+	return nic->nic_op->connect ( nic );
61
+}
62
+
63
+static inline int eth_poll ( int retrieve ) {
64
+	return nic->nic_op->poll ( nic, retrieve );
65
+}
66
+
67
+static inline void eth_transmit ( const char *dest, unsigned int type,
68
+				  unsigned int size, const void *packet ) {
69
+	nic->nic_op->transmit ( nic, dest, type, size, packet );
70
+}
71
+
72
+static inline void eth_irq ( irq_action_t action ) {
73
+	nic->nic_op->irq ( nic, action );
74
+}
75
+
76
+/* Should be using disable() rather than eth_disable() */
77
+static inline void eth_disable ( void ) __attribute__ (( deprecated ));
78
+static inline void eth_disable ( void ) {
79
+	nic->nic_op->disable ( nic );
80
+}
40 81
 
41
-extern struct nic nic;
42
-extern int  eth_probe(struct dev *dev);
43
-extern int  eth_poll(int retrieve);
44
-extern void eth_transmit(const char *d, unsigned int t, unsigned int s, const void *p);
45
-extern void eth_disable(void);
46
-extern void eth_irq(irq_action_t action);
47
-extern int eth_load_configuration(struct dev *dev);
48
-extern int eth_load(struct dev *dev);;
49 82
 #endif	/* NIC_H */

Завантаження…
Відмінити
Зберегти