Changeset 74864ac in mainline
- Timestamp:
- 2011-01-06T15:28:51Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0777f4c5
- Parents:
- fc23ef6
- Location:
- uspace/srv/hw/netif/dp8390
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390.c
rfc23ef6 r74864ac 46 46 #define CR_EXTRA CR_STA 47 47 48 _PROTOTYPE(static void dp_init, (dpeth_t *dep) ); 49 _PROTOTYPE(static void dp_reinit, (dpeth_t *dep) ); 50 _PROTOTYPE(static void dp_reset, (dpeth_t *dep) ); 51 _PROTOTYPE(static void dp_recv, (dpeth_t *dep) ); 52 _PROTOTYPE(static void dp_send, (dpeth_t *dep) ); 53 _PROTOTYPE(static void dp_pio8_getblock, (dpeth_t *dep, int page, 54 size_t offset, size_t size, void *dst) ); 55 _PROTOTYPE(static void dp_pio16_getblock, (dpeth_t *dep, int page, 56 size_t offset, size_t size, void *dst) ); 57 _PROTOTYPE(static int dp_pkt2user, (dpeth_t *dep, int page, 58 int length) ); 59 _PROTOTYPE(static void dp_pio8_user2nic, (dpeth_t *dep, 60 iovec_dat_t *iovp, vir_bytes offset, 61 int nic_addr, vir_bytes count) ); 62 _PROTOTYPE(static void dp_pio16_user2nic, (dpeth_t *dep, 63 iovec_dat_t *iovp, vir_bytes offset, 64 int nic_addr, vir_bytes count) ); 65 _PROTOTYPE(static void dp_pio8_nic2user, (dpeth_t *dep, int nic_addr, 66 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 67 _PROTOTYPE(static void dp_pio16_nic2user, (dpeth_t *dep, int nic_addr, 68 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 69 _PROTOTYPE(static void dp_next_iovec, (iovec_dat_t *iovp) ); 70 _PROTOTYPE(static void conf_hw, (dpeth_t *dep) ); 71 _PROTOTYPE(static void reply, (dpeth_t *dep, int err, int may_block) ); 72 _PROTOTYPE(static void get_userdata, (int user_proc, 73 vir_bytes user_addr, vir_bytes count, void *loc_addr) ); 74 _PROTOTYPE(static void insb, (port_t port, void *buf, size_t size) ); 75 _PROTOTYPE(static void insw, (port_t port, void *buf, size_t size) ); 48 static void dp_init(dpeth_t *dep); 49 static void dp_reinit(dpeth_t *dep); 50 static void dp_reset(dpeth_t *dep); 51 static void dp_recv(dpeth_t *dep); 52 static void dp_send(dpeth_t *dep); 53 static void dp_pio8_getblock(dpeth_t *dep, int page, size_t offset, size_t size, void *dst); 54 static void dp_pio16_getblock(dpeth_t *dep, int page, size_t offset, size_t size, void *dst); 55 static int dp_pkt2user(dpeth_t *dep, int page, int length); 56 static void dp_pio8_user2nic(dpeth_t *dep, iovec_dat_t *iovp, vir_bytes offset, int nic_addr, vir_bytes count); 57 static void dp_pio16_user2nic(dpeth_t *dep, iovec_dat_t *iovp, vir_bytes offset, int nic_addr, vir_bytes count); 58 static void dp_pio8_nic2user(dpeth_t *dep, int nic_addr, iovec_dat_t *iovp, vir_bytes offset, vir_bytes count); 59 static void dp_pio16_nic2user(dpeth_t *dep, int nic_addr, iovec_dat_t *iovp, vir_bytes offset, vir_bytes count); 60 static void dp_next_iovec(iovec_dat_t *iovp); 61 static void conf_hw(dpeth_t *dep); 62 static void reply(dpeth_t *dep, int err, int may_block); 63 static void get_userdata(int user_proc, vir_bytes user_addr, vir_bytes count, void *loc_addr); 64 static void insb(port_t port, void *buf, size_t size); 65 static void insw(port_t port, void *buf, size_t size); 76 66 77 67 int do_probe(dpeth_t *dep) … … 226 216 count = mp->DL_COUNT; 227 217 if (port < 0 || port >= DE_PORT_NR) 228 panic("", "dp8390: illegal port", port);218 fprintf(stderr, "dp8390: illegal port\n"); 229 219 dep= &de_table[port]; 230 220 dep->de_client= mp->DL_PROC; … … 233 223 assert(!from_int); 234 224 // dep->de_flags |= DEF_PACK_SEND; 235 reply(dep, EOK, FALSE);225 reply(dep, EOK, false); 236 226 // return; 237 227 return EOK; … … 243 233 if ((dep->packet_queue) && (!from_int)) { 244 234 // if (dep->de_flags &DEF_SEND_AVAIL){ 245 // panic("", "dp8390: send already in progress", NO_NUM);235 // fprintf(stderr, "dp8390: send already in progress\n"); 246 236 return queue_packet(dep, packet); 247 237 } … … 250 240 // if (dep->de_sendq[sendq_head].sq_filled) { 251 241 // if (from_int) 252 // panic("", "dp8390: should not be sending\n", NO_NUM);242 // fprintf(stderr, "dp8390: should not be sending\n"); 253 243 // dep->de_sendmsg= *mp; 254 244 // dep->de_flags |= DEF_SEND_AVAIL; 255 // reply(dep, EOK, FALSE);245 // reply(dep, EOK, false); 256 246 // return; 257 247 // return queue_packet(dep, packet); … … 287 277 288 278 if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE_TAGGED) { 289 panic("", "dp8390: invalid packet size", size);279 fprintf(stderr, "dp8390: invalid packet size\n"); 290 280 return EINVAL; 291 281 } … … 294 284 dep->de_sendq[sendq_head].sq_sendpage * DP_PAGESIZE, 295 285 size); 296 dep->de_sendq[sendq_head].sq_filled= TRUE;286 dep->de_sendq[sendq_head].sq_filled= true; 297 287 if (dep->de_sendq_tail == sendq_head) { 298 288 outb_reg0(dep, DP_TPSR, dep->de_sendq[sendq_head].sq_sendpage); … … 318 308 return EOK; 319 309 320 reply(dep, EOK, FALSE);310 reply(dep, EOK, false); 321 311 322 312 assert(dep->de_mode == DEM_ENABLED); … … 499 489 500 490 if (!(dep->de_flags &DEF_ENABLED)) 501 panic("", "dp8390: got premature interrupt", NO_NUM);491 fprintf(stderr, "dp8390: got premature interrupt\n"); 502 492 503 493 for(;;) … … 645 635 vir_bytes length; 646 636 int packet_processed, r; 647 u 16_t eth_type;648 649 packet_processed = FALSE;637 uint16_t eth_type; 638 639 packet_processed = false; 650 640 pageno = inb_reg0(dep, DP_BNRY) + 1; 651 641 if (pageno == dep->de_stoppage) pageno = dep->de_startpage; … … 714 704 return; 715 705 716 packet_processed = TRUE;706 packet_processed = true; 717 707 dep->de_stat.ets_packetR++; 718 708 } … … 741 731 packet = dep->packet_queue; 742 732 dep->packet_queue = pq_detach(packet); 743 do_pwrite(dep, packet, TRUE);733 do_pwrite(dep, packet, true); 744 734 netif_pq_release(packet_get_id(packet)); 745 735 -- dep->packet_count; … … 750 740 /* switch(dep->de_sendmsg.m_type) 751 741 { 752 case DL_WRITE: do_vwrite(&dep->de_sendmsg, TRUE, FALSE); break;753 case DL_WRITEV: do_vwrite(&dep->de_sendmsg, TRUE, TRUE); break;754 case DL_WRITEV_S: do_vwrite_s(&dep->de_sendmsg, TRUE); break;742 case DL_WRITE: do_vwrite(&dep->de_sendmsg, true, false); break; 743 case DL_WRITEV: do_vwrite(&dep->de_sendmsg, true, true); break; 744 case DL_WRITEV_S: do_vwrite_s(&dep->de_sendmsg, true); break; 755 745 default: 756 panic("", "dp8390: wrong type", dep->de_sendmsg.m_type);746 fprintf(stderr, "dp8390: wrong type\n"); 757 747 break; 758 748 } … … 914 904 } 915 905 if (i == 100) 916 { 917 panic("", "dp8390: remote dma failed to complete", NO_NUM); 918 } 906 fprintf(stderr, "dp8390: remote dma failed to complete\n"); 919 907 } 920 908 … … 933 921 int i, r, user_proc; 934 922 vir_bytes bytes; 935 //u 8_t two_bytes[2];936 u 16_t two_bytes;923 //uint8_t two_bytes[2]; 924 uint16_t two_bytes; 937 925 int odd_byte; 938 926 … … 973 961 r= sys_vircopy(user_proc, D, vir_user, 974 962 // SELF, D, (vir_bytes)&two_bytes[1], 1); 975 SELF, D, (vir_bytes)&(((u 8_t *)&two_bytes)[1]), 1);963 SELF, D, (vir_bytes)&(((uint8_t *)&two_bytes)[1]), 1); 976 964 if (r != EOK) 977 { 978 panic("DP8390", 979 "dp_pio16_user2nic: sys_vircopy failed", 980 r); 981 } 982 //outw(dep->de_data_port, *(u16_t *)two_bytes); 965 fprintf(stderr, "DP8390: dp_pio16_user2nic: sys_vircopy failed\n"); 966 967 //outw(dep->de_data_port, *(uint16_t *)two_bytes); 983 968 outw(dep->de_data_port, two_bytes); 984 969 count--; … … 1005 990 r= sys_vircopy(user_proc, D, vir_user, 1006 991 // SELF, D, (vir_bytes)&two_bytes[0], 1); 1007 SELF, D, (vir_bytes)&(((u 8_t *)&two_bytes)[0]), 1);992 SELF, D, (vir_bytes)&(((uint8_t *)&two_bytes)[0]), 1); 1008 993 if (r != EOK) 1009 { 1010 panic("DP8390", 1011 "dp_pio16_user2nic: sys_vircopy failed", 1012 r); 1013 } 994 fprintf(stderr, "DP8390: dp_pio16_user2nic: sys_vircopy failed\n"); 995 1014 996 count--; 1015 997 offset++; … … 1022 1004 1023 1005 if (odd_byte) 1024 //outw(dep->de_data_port, *(u 16_t *)two_bytes);1006 //outw(dep->de_data_port, *(uint16_t *)two_bytes); 1025 1007 outw(dep->de_data_port, two_bytes); 1026 1008 … … 1031 1013 } 1032 1014 if (i == 100) 1033 { 1034 panic("", "dp8390: remote dma failed to complete", NO_NUM); 1035 } 1015 fprintf(stderr, "dp8390: remote dma failed to complete\n"); 1036 1016 } 1037 1017 … … 1098 1078 int i, r, user_proc; 1099 1079 vir_bytes bytes; 1100 //u 8_t two_bytes[2];1101 u 16_t two_bytes;1080 //uint8_t two_bytes[2]; 1081 uint16_t two_bytes; 1102 1082 int odd_byte; 1103 1083 … … 1136 1116 { 1137 1117 //r= sys_vircopy(SELF, D, (vir_bytes)&two_bytes[1], 1138 r= sys_vircopy(SELF, D, (vir_bytes)&(((u 8_t *)&two_bytes)[1]),1118 r= sys_vircopy(SELF, D, (vir_bytes)&(((uint8_t *)&two_bytes)[1]), 1139 1119 user_proc, D, vir_user, 1); 1140 1120 if (r != EOK) 1141 { 1142 panic("DP8390", 1143 "dp_pio16_nic2user: sys_vircopy failed", 1144 r); 1145 } 1121 fprintf(stderr, "DP8390: dp_pio16_nic2user: sys_vircopy failed\n"); 1122 1146 1123 count--; 1147 1124 offset++; … … 1165 1142 { 1166 1143 assert(bytes == 1); 1167 //*(u 16_t *)two_bytes= inw(dep->de_data_port);1144 //*(uint16_t *)two_bytes= inw(dep->de_data_port); 1168 1145 two_bytes= inw(dep->de_data_port); 1169 1146 //r= sys_vircopy(SELF, D, (vir_bytes)&two_bytes[0], 1170 r= sys_vircopy(SELF, D, (vir_bytes)&(((u 8_t *)&two_bytes)[0]),1147 r= sys_vircopy(SELF, D, (vir_bytes)&(((uint8_t *)&two_bytes)[0]), 1171 1148 user_proc, D, vir_user, 1); 1172 1149 if (r != EOK) 1173 { 1174 panic("DP8390", 1175 "dp_pio16_nic2user: sys_vircopy failed", 1176 r); 1177 } 1150 fprintf(stderr, "DP8390: dp_pio16_nic2user: sys_vircopy failed\n"); 1151 1178 1152 count--; 1179 1153 offset++; … … 1271 1245 1272 1246 if (r < 0) 1273 panic("", "dp8390: send failed:", r);1247 fprintf(stderr, "dp8390: send failed\n"); 1274 1248 1275 1249 */ dep->de_read_s = 0; … … 1291 1265 SELF, D, (vir_bytes)loc_addr, count); 1292 1266 if (r != EOK) 1293 panic("DP8390", "get_userdata: sys_vircopy failed", r);1267 fprintf(stderr, "DP8390: get_userdata: sys_vircopy failed\n"); 1294 1268 } 1295 1269 -
uspace/srv/hw/netif/dp8390/dp8390.h
rfc23ef6 r74864ac 11 11 12 12 #include <net/packet.h> 13 14 13 #include "dp8390_port.h" 15 14 16 /** Input/output size. 17 */ 18 #define DP8390_IO_SIZE 0x020 15 /** Input/output size */ 16 #define DP8390_IO_SIZE 0x0020 19 17 20 18 /* National Semiconductor DP8390 Network Interface Controller. */ … … 166 164 #define RSR_DFR 0x80 /* In later manuals: Deferring */ 167 165 168 /** Type definition of the receive header. 169 */ 170 typedef struct dp_rcvhdr 171 { 172 /** Copy of rsr. 173 */ 174 u8_t dr_status; 175 /** Pointer to next packet. 176 */ 177 u8_t dr_next; 178 /** Receive Byte Count Low. 179 */ 180 u8_t dr_rbcl; 181 /** Receive Byte Count High. 182 */ 183 u8_t dr_rbch; 166 /** Type definition of the receive header 167 * 168 */ 169 typedef struct dp_rcvhdr { 170 /** Copy of rsr */ 171 uint8_t dr_status; 172 173 /** Pointer to next packet */ 174 uint8_t dr_next; 175 176 /** Receive Byte Count Low */ 177 uint8_t dr_rbcl; 178 179 /** Receive Byte Count High */ 180 uint8_t dr_rbch; 184 181 } dp_rcvhdr_t; 185 182 186 /** Page size. 187 */ 188 #define DP_PAGESIZE 256 189 190 /* Some macros to simplify accessing the dp8390 */ 183 /** Page size */ 184 #define DP_PAGESIZE 256 185 191 186 /** Reads 1 byte from the zero page register. 192 187 * @param[in] dep The network interface structure. … … 194 189 * @returns The read value. 195 190 */ 196 #define inb_reg0(dep, reg) 191 #define inb_reg0(dep, reg) (inb(dep->de_dp8390_port+reg)) 197 192 198 193 /** Writes 1 byte zero page register. … … 201 196 * @param[in] data The value to be written. 202 197 */ 203 #define outb_reg0(dep, reg, data) 198 #define outb_reg0(dep, reg, data) (outb(dep->de_dp8390_port+reg, data)) 204 199 205 200 /** Reads 1 byte from the first page register. … … 208 203 * @returns The read value. 209 204 */ 210 #define inb_reg1(dep, reg) 205 #define inb_reg1(dep, reg) (inb(dep->de_dp8390_port+reg)) 211 206 212 207 /** Writes 1 byte first page register. … … 215 210 * @param[in] data The value to be written. 216 211 */ 217 #define outb_reg1(dep, reg, data) 212 #define outb_reg1(dep, reg, data) (outb(dep->de_dp8390_port+reg, data)) 218 213 219 214 /* Software interface to the dp8390 driver */ … … 222 217 struct iovec_dat; 223 218 224 _PROTOTYPE(typedef void (*dp_initf_t), (struct dpeth *dep) ); 225 _PROTOTYPE(typedef void (*dp_stopf_t), (struct dpeth *dep) ); 226 _PROTOTYPE(typedef void (*dp_user2nicf_t), (struct dpeth *dep, 227 struct iovec_dat *iovp, vir_bytes offset, 228 int nic_addr, vir_bytes count) ); 229 _PROTOTYPE(typedef void (*dp_nic2userf_t), (struct dpeth *dep, 230 int nic_addr, struct iovec_dat *iovp, 231 vir_bytes offset, vir_bytes count) ); 232 _PROTOTYPE(typedef void (*dp_getblock_t), (struct dpeth *dep, 233 int page, size_t offset, size_t size, void *dst) ); 219 typedef void (*dp_initf_t)(struct dpeth *dep); 220 typedef void (*dp_stopf_t)(struct dpeth *dep); 221 typedef void (*dp_user2nicf_t)(struct dpeth *dep, struct iovec_dat *iovp, vir_bytes offset, int nic_addr, vir_bytes count); 222 typedef void (*dp_nic2userf_t)(struct dpeth *dep, int nic_addr, struct iovec_dat *iovp, vir_bytes offset, vir_bytes count); 223 typedef void (*dp_getblock_t)(struct dpeth *dep, int page, size_t offset, size_t size, void *dst); 234 224 235 225 #define IOVEC_NR 1 236 226 237 typedef struct iovec_dat 238 { 227 typedef struct iovec_dat { 239 228 iovec_t iod_iovec[IOVEC_NR]; 240 229 int iod_iovec_s; 241 // no direct process access242 230 int iod_proc_nr; 243 231 vir_bytes iod_iovec_addr; 244 232 } iovec_dat_t; 245 /* 246 typedef struct iovec_dat_s 247 { 248 iovec_s_t iod_iovec[IOVEC_NR]; 249 int iod_iovec_s; 250 int iod_proc_nr; 251 cp_grant_id_t iod_grant; 252 vir_bytes iod_iovec_offset; 253 } iovec_dat_s_t; 254 */ 255 #define SENDQ_NR 1 /* Maximum size of the send queue */ 256 #define SENDQ_PAGES 6 /* 6 * DP_PAGESIZE >= 1514 bytes */ 233 234 #define SENDQ_NR 1 /* Maximum size of the send queue */ 235 #define SENDQ_PAGES 6 /* 6 * DP_PAGESIZE >= 1514 bytes */ 257 236 258 237 /** Maximum number of waiting packets to be sent or received. … … 260 239 #define MAX_PACKETS 4 261 240 262 typedef struct dpeth 263 { 264 /** Outgoing packets queue. 265 */ 241 typedef struct dpeth { 242 /** Outgoing packets queue */ 266 243 packet_t *packet_queue; 267 244 268 /** Outgoing packets count. 269 */ 245 /** Outgoing packets count */ 270 246 int packet_count; 271 247 272 /** Received packets queue. 273 */ 248 /** Received packets queue */ 274 249 packet_t *received_queue; 275 250 276 /** Received packets count. 277 */ 251 /** Received packets count */ 278 252 int received_count; 279 280 /* The de_base_port field is the starting point of the probe. 253 254 /* 255 * The de_base_port field is the starting point of the probe. 281 256 * The conf routine also fills de_linmem and de_irq. If the probe 282 257 * routine knows the irq and/or memory address because they are … … 293 268 char de_name[sizeof("dp8390#n")]; 294 269 295 /* The initf function fills the following fields. Only cards that do 270 /* 271 * The initf function fills the following fields. Only cards that do 296 272 * programmed I/O fill in the de_pata_port field. 297 273 * In addition, the init routine has to fill in the sendq data … … 309 285 /* Do it yourself send queue */ 310 286 struct sendq { 311 int sq_filled; 312 int sq_size; 313 int sq_sendpage; 287 int sq_filled; /* this buffer contains a packet */ 288 int sq_size; /* with this size */ 289 int sq_sendpage; /* starting page of the buffer */ 314 290 } de_sendq[SENDQ_NR]; 315 291 316 292 int de_sendq_nr; 317 int de_sendq_head; 318 int de_sendq_tail; 293 int de_sendq_head; /* Enqueue at the head */ 294 int de_sendq_tail; /* Dequeue at the tail */ 319 295 320 296 /* Fields for internal use by the dp8390 driver. */ … … 333 309 } dpeth_t; 334 310 335 #define DEI_DEFAULT 336 337 #define DEF_EMPTY 338 #define DEF_PACK_SEND 339 #define DEF_PACK_RECV 340 #define DEF_SEND_AVAIL 341 #define DEF_READING 342 #define DEF_PROMISC 343 #define DEF_MULTI 344 #define DEF_BROAD 345 #define DEF_ENABLED 346 #define DEF_STOPPED 347 348 #define DEM_DISABLED 349 #define DEM_SINK 350 #define DEM_ENABLED 311 #define DEI_DEFAULT 0x8000 312 313 #define DEF_EMPTY 0x000 314 #define DEF_PACK_SEND 0x001 315 #define DEF_PACK_RECV 0x002 316 #define DEF_SEND_AVAIL 0x004 317 #define DEF_READING 0x010 318 #define DEF_PROMISC 0x040 319 #define DEF_MULTI 0x080 320 #define DEF_BROAD 0x100 321 #define DEF_ENABLED 0x200 322 #define DEF_STOPPED 0x400 323 324 #define DEM_DISABLED 0x0 325 #define DEM_SINK 0x1 326 #define DEM_ENABLED 0x2 351 327 352 328 #endif -
uspace/srv/hw/netif/dp8390/dp8390_module.c
rfc23ef6 r74864ac 261 261 do{ 262 262 next = pq_detach(packet); 263 if(do_pwrite(dep, packet, FALSE) != EBUSY){263 if(do_pwrite(dep, packet, false) != EBUSY){ 264 264 netif_pq_release(packet_get_id(packet)); 265 265 } -
uspace/srv/hw/netif/dp8390/dp8390_port.h
rfc23ef6 r74864ac 44 44 #include <sys/types.h> 45 45 46 /** Macro for difining functions.47 * @param[in] function The function type and name definition.48 * @param[in] params The function parameters definition.49 */50 #define _PROTOTYPE(function, params) function params51 52 /** Type definition of the unsigned byte.53 */54 typedef uint8_t u8_t;55 56 /** Type definition of the unsigned short.57 */58 typedef uint16_t u16_t;59 60 46 /** Compares two memory blocks. 61 47 * @param[in] first The first memory block. … … 66 52 * @returns 1 if the second is greater than the first. 67 53 */ 68 #define memcmp(first, second, size) 54 #define memcmp(first, second, size) bcmp((char *) (first), (char *) (second), (size)) 69 55 70 56 /** Reads 1 byte. … … 72 58 * @returns The read value. 73 59 */ 74 #define inb(port) 60 #define inb(port) pio_read_8((ioport8_t *) (port)) 75 61 76 62 /** Reads 1 word (2 bytes). … … 78 64 * @returns The read value. 79 65 */ 80 #define inw(port) 66 #define inw(port) pio_read_16((ioport16_t *) (port)) 81 67 82 68 /** Writes 1 byte. … … 84 70 * @param[in] value The value to be written. 85 71 */ 86 #define outb(port, value) 72 #define outb(port, value) pio_write_8((ioport8_t *) (port), (value)) 87 73 88 74 /** Writes 1 word (2 bytes). … … 90 76 * @param[in] value The value to be written. 91 77 */ 92 #define outw(port, value) pio_write_16((ioport16_t *) (port), (value)) 93 94 /** Prints out the driver critical error. 95 * Does not call the system panic(). 96 */ 97 #define panic(...) printf("%s%s%d", __VA_ARGS__) 78 #define outw(port, value) pio_write_16((ioport16_t *) (port), (value)) 98 79 99 80 /** Copies a memory block. … … 141 122 #define do_vir_outsw(port, proc, src, bytes) outsw((port), (void *)(src), (bytes)) 142 123 143 /* com.h */144 124 /* Bits in 'DL_MODE' field of DL requests. */ 145 # define DL_NOMODE 0x0 146 # define DL_PROMISC_REQ 0x2 147 # define DL_MULTI_REQ 0x4 148 # define DL_BROAD_REQ 0x8 149 150 /* const.h */ 151 /** True value. 152 */ 153 #define TRUE 1 /* used for turning integers into Booleans */ 154 155 /** False value. 156 */ 157 #define FALSE 0 /* used for turning integers into Booleans */ 158 159 /** No number value. 160 */ 161 #define NO_NUM 0x8000 /* used as numerical argument to panic() */ 162 163 /* devio.h */ 164 //typedef u16_t port_t; 125 #define DL_NOMODE 0x0 126 #define DL_PROMISC_REQ 0x2 127 #define DL_MULTI_REQ 0x4 128 #define DL_BROAD_REQ 0x8 129 165 130 /** Type definition of a port. 166 131 */ 167 132 typedef long port_t; 168 133 169 /* dl_eth.h */170 134 /** Ethernet statistics. 171 135 */ 172 typedef struct eth_stat 173 { 136 typedef struct eth_stat { 174 137 /** Number of receive errors. 175 138 */ … … 242 205 /** Address data. 243 206 */ 244 u 8_t ea_addr[6];207 uint8_t ea_addr[6]; 245 208 } ether_addr_t; 246 209 -
uspace/srv/hw/netif/dp8390/ne2000.c
rfc23ef6 r74864ac 16 16 #define N 100 17 17 18 typedef int (*testf_t)(dpeth_t *dep, int pos, u 8_t *pat);18 typedef int (*testf_t)(dpeth_t *dep, int pos, uint8_t *pat); 19 19 20 20 /** Data patterns */ 21 u 8_t pat0[] = {0x00, 0x00, 0x00, 0x00};22 u 8_t pat1[] = {0xFF, 0xFF, 0xFF, 0xFF};23 u 8_t pat2[] = {0xA5, 0x5A, 0x69, 0x96};24 u 8_t pat3[] = {0x96, 0x69, 0x5A, 0xA5};21 uint8_t pat0[] = {0x00, 0x00, 0x00, 0x00}; 22 uint8_t pat1[] = {0xFF, 0xFF, 0xFF, 0xFF}; 23 uint8_t pat2[] = {0xA5, 0x5A, 0x69, 0x96}; 24 uint8_t pat3[] = {0x96, 0x69, 0x5A, 0xA5}; 25 25 26 26 /** Tests 8 bit NE2000 network interface. … … 29 29 * @param[in] pat The data pattern to be written. 30 30 * @returns True on success. 31 * @returns FALSEotherwise.32 */ 33 static int test_8(dpeth_t *dep, int pos, u 8_t *pat);31 * @returns false otherwise. 32 */ 33 static int test_8(dpeth_t *dep, int pos, uint8_t *pat); 34 34 35 35 /** Tests 16 bit NE2000 network interface. … … 38 38 * @param[in] pat The data pattern to be written. 39 39 * @returns True on success. 40 * @returns FALSEotherwise.41 */ 42 static int test_16(dpeth_t *dep, int pos, u 8_t *pat);40 * @returns false otherwise. 41 */ 42 static int test_16(dpeth_t *dep, int pos, uint8_t *pat); 43 43 44 44 /** Stops the NE2000 network interface. … … 178 178 } 179 179 180 static int test_8(dpeth_t *dep, int pos, u 8_t *pat)181 { 182 u 8_t buf[4];180 static int test_8(dpeth_t *dep, int pos, uint8_t *pat) 181 { 182 uint8_t buf[4]; 183 183 int i; 184 184 … … 217 217 } 218 218 219 static int test_16(dpeth_t *dep, int pos, u 8_t *pat)220 { 221 u 8_t buf[4];219 static int test_16(dpeth_t *dep, int pos, uint8_t *pat) 220 { 221 uint8_t buf[4]; 222 222 int i; 223 223 … … 232 232 233 233 for (i = 0; i < 4; i += 2) 234 outw_ne(dep, NE_DATA, *(u 16_t *)(pat + i));234 outw_ne(dep, NE_DATA, *(uint16_t *)(pat + i)); 235 235 236 236 for (i = 0; i < N; i++) { … … 251 251 252 252 for (i = 0; i < 4; i += 2) 253 *(u 16_t *)(buf + i) = inw_ne(dep, NE_DATA);253 *(uint16_t *)(buf + i) = inw_ne(dep, NE_DATA); 254 254 255 255 return (memcmp(buf, pat, 4) == 0);
Note:
See TracChangeset
for help on using the changeset viewer.