|
|
1.1 root 1: /******************************************************************************
2: * Copyright (c) 2004, 2008 IBM Corporation
3: * All rights reserved.
4: * This program and the accompanying materials
5: * are made available under the terms of the BSD License
6: * which accompanies this distribution, and is available at
7: * http://www.opensource.org/licenses/bsd-license.php
8: *
9: * Contributors:
10: * IBM Corporation - initial implementation
11: *****************************************************************************/
12:
13: #ifndef _NETDRIVER_INT_H
14: #define _NETDRIVER_INT_H
15: #include <stddef.h>
16: #include <unistd.h> /* ssize_t */
17: #include <fileio.h>
18:
19: #if defined(__GNUC__) && !defined(UNUSED)
20: # define UNUSED __attribute__((unused))
21: #else
22: # define UNUSED
23: #endif
24:
25: typedef struct {
26: unsigned int addr;
27: unsigned int size;
28: int type;
29: } bar_t;
30:
1.1.1.2 ! root 31: typedef enum {
! 32: CONFIG_TYPE_PCI,
! 33: CONFIG_TYPE_VIO
! 34: } mod_config_type;
1.1 root 35:
36: typedef struct {
1.1.1.2 ! root 37: mod_config_type config_type;
1.1 root 38: unsigned long long puid;
39: unsigned int bus;
40: unsigned int devfn;
41: unsigned int vendor_id;
42: unsigned int device_id;
43: unsigned int revision_id;
44: unsigned int class_code;
45: bar_t bars[6];
46: unsigned int interrupt_line;
47: } pci_config_t;
48:
49: typedef struct {
1.1.1.2 ! root 50: mod_config_type config_type;
! 51: unsigned int reg_len;
! 52: unsigned int reg[12];
1.1 root 53: char compat[64];
54: } vio_config_t;
55:
56: #define MOD_TYPE_NETWORK 0
57: #define MOD_TYPE_OTHER 1
58:
59: typedef int (*mod_init_t) (void);
60: typedef int (*mod_term_t) (void);
61: typedef int (*mod_socket_t)(snk_fileio_t *, int dom, int type, int proto);
62: typedef int (*mod_open_t) (snk_fileio_t *, const char *, int);
63: typedef int (*mod_read_t) (char *, int);
64: typedef int (*mod_write_t) (char *, int);
65: typedef int (*mod_ioctl_t) (int, void *);
66:
67: typedef struct {
68: int version;
69: int type;
70: int running;
71: void *link_addr;
72: mod_init_t init;
73: mod_term_t term;
74: mod_socket_t socket;
75: mod_open_t open;
76: mod_read_t read;
77: mod_write_t write;
78: mod_ioctl_t ioctl;
79:
80: char mac_addr[6];
81: } snk_module_t;
82:
83: #define MODULES_MAX 10
84: extern snk_module_t *snk_modules[MODULES_MAX];
85:
86: typedef int (*print_t) (const char *, ...);
87: typedef void (*us_delay_t) (unsigned int);
88: typedef void (*ms_delay_t) (unsigned int);
89: typedef int (*pci_config_read_t) (long long puid, int size,
90: int bus, int devfn, int offset);
91: typedef int (*pci_config_write_t) (long long puid, int size,
92: int bus, int devfn, int offset, int value);
93: typedef void *(*malloc_aligned_t) (size_t, int);
94: typedef void *(*malloc_t) (size_t);
95: typedef void (*free_t) (void *);
96: typedef int (*strcmp_t) (const char *, const char *);
97: typedef int (*snk_call_t) (int, char **);
98: typedef unsigned int (*io_read_t) (void *, size_t);
99: typedef int (*io_write_t) (void *, unsigned int, size_t);
100: typedef unsigned int (*romfs_lookup_t) (const char *name, void **addr);
101: typedef void (*translate_addr_t) (unsigned long *);
102:
103: typedef int (*k_open_t) (const char *, int);
104: typedef int (*k_close_t) (int);
105: typedef ssize_t (*k_read_t) (int, void *, size_t);
106: typedef ssize_t (*k_write_t) (int, const void *, size_t);
107: typedef int (*k_ioctl_t) (int, int, void *);
108:
109: typedef void (*modules_remove_t) (int);
110: typedef snk_module_t *(*modules_load_t) (int);
111:
1.1.1.2 ! root 112: typedef long (*dma_map_in_t)(void *address, long size, int cachable);
! 113: typedef void (*dma_map_out_t)(void *address, long devaddr, long size);
! 114:
1.1 root 115: typedef struct {
116: int version;
117: print_t print;
118: us_delay_t us_delay;
119: ms_delay_t ms_delay;
120: pci_config_read_t pci_config_read;
121: pci_config_write_t pci_config_write;
122: malloc_t k_malloc;
123: malloc_aligned_t k_malloc_aligned;
124: free_t k_free;
125: strcmp_t strcmp;
126: snk_call_t snk_call;
127: io_read_t io_read;
128: io_write_t io_write;
129: romfs_lookup_t k_romfs_lookup;
130: translate_addr_t translate_addr;
131: union {
132: pci_config_t pci_conf;
133: vio_config_t vio_conf;
134: };
135: k_open_t k_open;
136: k_close_t k_close;
137: k_read_t k_read;
138: k_write_t k_write;
139: k_ioctl_t k_ioctl;
140: modules_remove_t modules_remove;
141: modules_load_t modules_load;
1.1.1.2 ! root 142: dma_map_in_t dma_map_in;
! 143: dma_map_out_t dma_map_out;
1.1 root 144: } snk_kernel_t;
145:
146: /* Entry of module */
147: snk_module_t *module_init(snk_kernel_t * snk_kernel_int,
148: pci_config_t * pciconf);
149:
150:
151: /*
152: * Constants for different kinds of IOCTL requests
153: */
154:
155: #define SIOCETHTOOL 0x1000
156:
157: /*
158: * special structure and constants for IOCTL requests of type ETHTOOL
159: */
160:
161: #define ETHTOOL_GMAC 0x03
162: #define ETHTOOL_SMAC 0x04
163: #define ETHTOOL_VERSION 0x05
164:
165: typedef struct {
166: int idx;
167: char address[6];
168: } ioctl_ethtool_mac_t;
169:
170: typedef struct {
171: unsigned int length;
172: char *text;
173: } ioctl_ethtool_version_t;
174:
175:
176: /*
177: * default structure and constants for IOCTL requests
178: */
179:
180: #define IF_NAME_SIZE 0xFF
181:
182: typedef struct {
183: char if_name[IF_NAME_SIZE];
184: int subcmd;
185: union {
186: ioctl_ethtool_mac_t mac;
187: ioctl_ethtool_version_t version;
188: } data;
189: } ioctl_net_data_t;
190:
191: #endif /* _NETDRIVER_INT_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.