ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/include/ether_defs.h
(Generate patch)

Comparing SheepShaver/src/include/ether_defs.h (file contents):
Revision 1.1 by cebix, 2002-02-04T16:58:13Z vs.
Revision 1.4 by gbeauche, 2004-05-10T15:42:35Z

# Line 1 | Line 1
1   /*
2   *  ether_defs.h - Definitions for DLPI Ethernet Driver
3   *
4 < *  SheepShaver (C) 1997-2002 Marc Hellwig and Christian Bauer
4 > *  SheepShaver (C) 1997-2004 Marc Hellwig and Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 189 | Line 189 | enum EAddrType {
189  
190  
191   /*
192 + *  Data member wrappers
193 + */
194 +
195 + // Forward declarations
196 + struct datab;
197 + struct msgb;
198 + struct queue;
199 + struct multicast_node;
200 + struct DLPIStream;
201 +
202 + // Optimize for 32-bit big endian targets
203 + #if defined(WORDS_BIGENDIAN) && (SIZEOF_VOID_P == 4)
204 +
205 + // Predefined member types
206 + typedef int8                    nw_int8;
207 + typedef int16                   nw_int16;
208 + typedef int32                   nw_int32;
209 + typedef uint8                   nw_uint8;
210 + typedef uint16                  nw_uint16;
211 + typedef uint32                  nw_uint32;
212 + typedef bool                    nw_bool;
213 + typedef uint8 *                 nw_uint8_p;
214 + typedef void *                  nw_void_p;
215 + typedef datab *                 nw_datab_p;
216 + typedef msgb *                  nw_msgb_p;
217 + typedef queue *                 nw_queue_p;
218 + typedef multicast_node *nw_multicast_node_p;
219 + typedef DLPIStream *    nw_DLPIStream_p;
220 +
221 + #else
222 +
223 + // Big-endian memory accessor
224 + template< int nbytes >
225 + struct nw_memory_helper;
226 +
227 + template<>
228 + struct nw_memory_helper<1> {
229 +        static inline uint8 load(void *ptr) { return *((uint8 *)ptr); }
230 +        static inline void store(void *ptr, uint8 val) { *((uint8 *)ptr) = val; }
231 + };
232 +
233 + template<>
234 + struct nw_memory_helper<2> {
235 +        static inline uint16 load(void *ptr) { return ntohs(*((uint16 *)ptr)); }
236 +        static inline void  store(void *ptr, uint16 val) { *((uint16 *)ptr) = htons(val); }
237 + };
238 +
239 + template<>
240 + struct nw_memory_helper<4> {
241 +        static inline uint32 load(void *ptr) { return ntohl(*((uint32 *)ptr)); }
242 +        static inline void  store(void *ptr, uint32 val) { *((uint32 *)ptr) = htonl(val); }
243 + };
244 +
245 + // Scalar data member wrapper (specialise for pointer member types?)
246 + template< class type, class public_type >
247 + class nw_scalar_member_helper {
248 +        uint8 _pad[sizeof(type)];
249 + public:
250 +        operator public_type () const {
251 +                return (public_type)nw_memory_helper<sizeof(type)>::load((void *)this);
252 +        }
253 +        public_type operator -> () const {
254 +                return this->operator public_type ();
255 +        }
256 +        nw_scalar_member_helper<type, public_type> & operator = (public_type val) {
257 +                nw_memory_helper<sizeof(type)>::store((void *)this, (type)val);
258 +                return *this;
259 +        }
260 +        nw_scalar_member_helper<type, public_type> & operator += (int val) {
261 +                *this = *this + val;
262 +                return *this;
263 +        }
264 +        nw_scalar_member_helper<type, public_type> & operator -= (int val) {
265 +                *this = *this - val;
266 +                return *this;
267 +        }
268 +        nw_scalar_member_helper<type, public_type> & operator &= (int val) {
269 +                *this = *this & val;
270 +                return *this;
271 +        }
272 +        nw_scalar_member_helper<type, public_type> & operator |= (int val) {
273 +                *this = *this | val;
274 +                return *this;
275 +        }
276 + };
277 +
278 + // Predefined member types
279 + typedef nw_scalar_member_helper<uint8, int8>                    nw_int8;
280 + typedef nw_scalar_member_helper<uint16, int16>                  nw_int16;
281 + typedef nw_scalar_member_helper<uint32, int32>                  nw_int32;
282 + typedef nw_scalar_member_helper<uint8, uint8>                   nw_uint8;
283 + typedef nw_scalar_member_helper<uint16, uint16>                 nw_uint16;
284 + typedef nw_scalar_member_helper<uint32, uint32>                 nw_uint32;
285 + typedef nw_scalar_member_helper<int, bool>                              nw_bool;
286 + typedef nw_scalar_member_helper<uint32, uint8 *>                nw_uint8_p;
287 + typedef nw_scalar_member_helper<uint32, void *>                 nw_void_p;
288 + typedef nw_scalar_member_helper<uint32, datab *>                nw_datab_p;
289 + typedef nw_scalar_member_helper<uint32, msgb *>                 nw_msgb_p;
290 + typedef nw_scalar_member_helper<uint32, queue *>                nw_queue_p;
291 + typedef nw_scalar_member_helper<uint32, multicast_node *> nw_multicast_node_p;
292 + typedef nw_scalar_member_helper<uint32, DLPIStream *>   nw_DLPIStream_p;
293 +
294 + #endif
295 +
296 +
297 + /*
298   *  Structures
299   */
300  
301   // Data block
302   struct datab {
303 <        datab *db_freep;
304 <        uint8 *db_base;
305 <        uint8 *db_lim;
306 <        uint8 db_ref;
307 <        uint8 db_type;
303 >        nw_datab_p db_freep;
304 >        nw_uint8_p db_base;
305 >        nw_uint8_p db_lim;
306 >        nw_uint8   db_ref;
307 >        nw_uint8   db_type;
308          // ...
309   };
310  
311   // Message block
312   struct msgb {
313 <        msgb *b_next;
314 <        msgb *b_prev;
315 <        msgb *b_cont;
316 <        uint8 *b_rptr;
317 <        uint8 *b_wptr;
318 <        datab *b_datap;
313 >        nw_msgb_p  b_next;
314 >        nw_msgb_p  b_prev;
315 >        nw_msgb_p  b_cont;
316 >        nw_uint8_p b_rptr;
317 >        nw_uint8_p b_wptr;
318 >        nw_datab_p b_datap;
319          // ...
320   };
321  
322   // Queue (full structure required because of size)
323   struct queue {
324 <        void *q_qinfo;
325 <        msgb *q_first;
326 <        msgb *q_last;
327 <        queue *q_next;
328 <        queue *q_link;
329 <        void *q_ptr;
330 <        uint32 q_count;
331 <        int32 q_minpsz;
332 <        int32 q_maxpsz;
333 <        uint32 q_hiwat;
334 <        uint32 q_lowat;
335 <        void *q_bandp;
336 <        uint16 q_flag;
337 <        uint8 q_nband;
338 <        uint8 q_pad1[1];
339 <        void *q_osx;
340 <        queue *q_ffcp;
341 <        queue *q_bfcp;
324 >        nw_void_p q_qinfo;
325 >        nw_msgb_p q_first;
326 >        nw_msgb_p q_last;
327 >        nw_queue_p q_next;
328 >        nw_queue_p q_link;
329 >        nw_DLPIStream_p q_ptr;
330 >        nw_uint32 q_count;
331 >        nw_int32 q_minpsz;
332 >        nw_int32 q_maxpsz;
333 >        nw_uint32 q_hiwat;
334 >        nw_uint32 q_lowat;
335 >        nw_void_p q_bandp;
336 >        nw_uint16 q_flag;
337 >        nw_uint8 q_nband;
338 >        uint8 _q_pad1[1];
339 >        nw_void_p q_osx;
340 >        nw_queue_p q_ffcp;
341 >        nw_queue_p q_bfcp;
342   };
343   typedef struct queue queue_t;
344  
345   // M_IOCTL parameters
346   struct iocblk {
347 <        int32 ioc_cmd;
348 <        void *ioc_cr;
349 <        uint32 ioc_id;
350 <        uint32 ioc_count;
351 <        int32 ioc_error;
352 <        int32 ioc_rval;
353 <        int32 ioc_filler[4];
347 >        nw_int32 ioc_cmd;
348 >        nw_void_p ioc_cr;
349 >        nw_uint32 ioc_id;
350 >        nw_uint32 ioc_count;
351 >        nw_int32 ioc_error;
352 >        nw_int32 ioc_rval;
353 >        int32 _ioc_filler[4];
354   };
355  
356   // Priority specification
357   struct dl_priority_t {
358 <        int32 dl_min, dl_max;
358 >        nw_int32 dl_min, dl_max;
359   };
360  
361   // DPLI primitives
362   struct dl_info_req_t {
363 <        uint32 dl_primitive; // DL_INFO_REQ
363 >        nw_uint32 dl_primitive; // DL_INFO_REQ
364   };
365  
366   struct dl_info_ack_t {
367 <        uint32 dl_primitive; // DL_INFO_ACK
368 <    uint32 dl_max_sdu;
369 <    uint32 dl_min_sdu;
370 <    uint32 dl_addr_length;
371 <    uint32 dl_mac_type;
372 <    uint32 dl_reserved;
373 <    uint32 dl_current_state;
374 <    int32 dl_sap_length;
375 <    uint32 dl_service_mode;
376 <    uint32 dl_qos_length;
377 <    uint32 dl_qos_offset;
378 <    uint32 dl_qos_range_length;
379 <    uint32 dl_qos_range_offset;
380 <    uint32 dl_provider_style;
381 <    uint32 dl_addr_offset;
382 <    uint32 dl_version;
383 <    uint32 dl_brdcst_addr_length;
384 <    uint32 dl_brdcst_addr_offset;
385 <    uint32 dl_growth;
367 >        nw_uint32 dl_primitive; // DL_INFO_ACK
368 >    nw_uint32 dl_max_sdu;
369 >    nw_uint32 dl_min_sdu;
370 >    nw_uint32 dl_addr_length;
371 >    nw_uint32 dl_mac_type;
372 >    nw_uint32 dl_reserved;
373 >    nw_uint32 dl_current_state;
374 >    nw_int32 dl_sap_length;
375 >    nw_uint32 dl_service_mode;
376 >    nw_uint32 dl_qos_length;
377 >    nw_uint32 dl_qos_offset;
378 >    nw_uint32 dl_qos_range_length;
379 >    nw_uint32 dl_qos_range_offset;
380 >    nw_uint32 dl_provider_style;
381 >    nw_uint32 dl_addr_offset;
382 >    nw_uint32 dl_version;
383 >    nw_uint32 dl_brdcst_addr_length;
384 >    nw_uint32 dl_brdcst_addr_offset;
385 >    nw_uint32 dl_growth;
386   };
387  
388   struct dl_bind_req_t {
389 <        uint32 dl_primitive; // DL_BIND_REQ
390 <        uint32 dl_sap;
391 <        uint32 dl_max_conind;
392 <        uint16 dl_service_mode;
393 <        uint16 dl_conn_mgmt;
394 <        uint32 dl_xidtest_flg;
389 >        nw_uint32 dl_primitive; // DL_BIND_REQ
390 >        nw_uint32 dl_sap;
391 >        nw_uint32 dl_max_conind;
392 >        nw_uint16 dl_service_mode;
393 >        nw_uint16 dl_conn_mgmt;
394 >        nw_uint32 dl_xidtest_flg;
395   };
396  
397   struct dl_bind_ack_t {
398 <        uint32 dl_primitive; // DL_BIND_ACK
399 <        uint32 dl_sap;
400 <        uint32 dl_addr_length;
401 <        uint32 dl_addr_offset;
402 <        uint32 dl_max_conind;
403 <        uint32 dl_xidtest_flg;
398 >        nw_uint32 dl_primitive; // DL_BIND_ACK
399 >        nw_uint32 dl_sap;
400 >        nw_uint32 dl_addr_length;
401 >        nw_uint32 dl_addr_offset;
402 >        nw_uint32 dl_max_conind;
403 >        nw_uint32 dl_xidtest_flg;
404   };
405  
406   struct dl_error_ack_t {
407 <        uint32 dl_primitive; // DL_ERROR_ACK
408 <        uint32 dl_error_primitive;
409 <        uint32 dl_errno;
410 <        uint32 dl_unix_errno;
407 >        nw_uint32 dl_primitive; // DL_ERROR_ACK
408 >        nw_uint32 dl_error_primitive;
409 >        nw_uint32 dl_errno;
410 >        nw_uint32 dl_unix_errno;
411   };
412  
413   struct dl_ok_ack_t {
414 <        uint32 dl_primitive; // DL_ERROR_ACK
415 <        uint32 dl_correct_primitive;
414 >        nw_uint32 dl_primitive; // DL_ERROR_ACK
415 >        nw_uint32 dl_correct_primitive;
416   };
417  
418   struct dl_unitdata_req_t {
419 <        uint32 dl_primitive; // DL_UNITDATA_REQ
420 <        uint32 dl_dest_addr_length;
421 <        uint32 dl_dest_addr_offset;
419 >        nw_uint32 dl_primitive; // DL_UNITDATA_REQ
420 >        nw_uint32 dl_dest_addr_length;
421 >        nw_uint32 dl_dest_addr_offset;
422          dl_priority_t   dl_priority;
423   };
424  
425   struct dl_unitdata_ind_t {
426 <        uint32 dl_primitive; // DL_UNITDATA_IND
427 <        uint32 dl_dest_addr_length;
428 <        uint32 dl_dest_addr_offset;
429 <        uint32 dl_src_addr_length;
430 <        uint32 dl_src_addr_offset;
431 <        uint32 dl_group_address;
426 >        nw_uint32 dl_primitive; // DL_UNITDATA_IND
427 >        nw_uint32 dl_dest_addr_length;
428 >        nw_uint32 dl_dest_addr_offset;
429 >        nw_uint32 dl_src_addr_length;
430 >        nw_uint32 dl_src_addr_offset;
431 >        nw_uint32 dl_group_address;
432   };
433  
434   struct dl_uderror_ind_t {
435 <        uint32 dl_primitive; // DL_UDERROR_IND
436 <        uint32 dl_dest_addr_length;
437 <        uint32 dl_dest_addr_offset;
438 <        uint32 dl_unix_errno;
439 <        uint32 dl_errno;
435 >        nw_uint32 dl_primitive; // DL_UDERROR_IND
436 >        nw_uint32 dl_dest_addr_length;
437 >        nw_uint32 dl_dest_addr_offset;
438 >        nw_uint32 dl_unix_errno;
439 >        nw_uint32 dl_errno;
440   };
441  
442   struct dl_subs_bind_req_t {
443 <        uint32 dl_primitive; // DL_SUBS_BIND_REQ
444 <        uint32 dl_subs_sap_offset;
445 <        uint32 dl_subs_sap_length;
446 <        uint32 dl_subs_bind_class;
443 >        nw_uint32 dl_primitive; // DL_SUBS_BIND_REQ
444 >        nw_uint32 dl_subs_sap_offset;
445 >        nw_uint32 dl_subs_sap_length;
446 >        nw_uint32 dl_subs_bind_class;
447   };
448  
449   struct dl_subs_bind_ack_t {
450 <        uint32 dl_primitive; // DL_SUBS_BIND_ACK
451 <        uint32 dl_subs_sap_offset;
452 <        uint32 dl_subs_sap_length;
450 >        nw_uint32 dl_primitive; // DL_SUBS_BIND_ACK
451 >        nw_uint32 dl_subs_sap_offset;
452 >        nw_uint32 dl_subs_sap_length;
453   };
454  
455   struct dl_subs_unbind_req_t {
456 <        uint32 dl_primitive; // DL_SUBS_UNBIND_REQ
457 <        uint32 dl_subs_sap_offset;
458 <        uint32 dl_subs_sap_length;
456 >        nw_uint32 dl_primitive; // DL_SUBS_UNBIND_REQ
457 >        nw_uint32 dl_subs_sap_offset;
458 >        nw_uint32 dl_subs_sap_length;
459   };
460  
461   struct dl_enabmulti_req_t {
462 <        uint32 dl_primitive; // DL_ENABMULTI_REQ
463 <        uint32 dl_addr_length;
464 <        uint32 dl_addr_offset;
462 >        nw_uint32 dl_primitive; // DL_ENABMULTI_REQ
463 >        nw_uint32 dl_addr_length;
464 >        nw_uint32 dl_addr_offset;
465   };
466  
467   struct dl_disabmulti_req_t {
468 <        uint32 dl_primitive; // DL_DISABMULTI_REQ
469 <        uint32 dl_addr_length;
470 <        uint32 dl_addr_offset;
468 >        nw_uint32 dl_primitive; // DL_DISABMULTI_REQ
469 >        nw_uint32 dl_addr_length;
470 >        nw_uint32 dl_addr_offset;
471   };
472  
473   struct dl_phys_addr_req_t {
474 <        uint32 dl_primitive; // DL_PHYS_ADDR_REQ
475 <        uint32 dl_addr_type;
474 >        nw_uint32 dl_primitive; // DL_PHYS_ADDR_REQ
475 >        nw_uint32 dl_addr_type;
476   };
477  
478   struct dl_phys_addr_ack_t {
479 <        uint32 dl_primitive; // DL_PHYS_ADDR_ACK
480 <        uint32 dl_addr_length;
481 <        uint32 dl_addr_offset;
479 >        nw_uint32 dl_primitive; // DL_PHYS_ADDR_ACK
480 >        nw_uint32 dl_addr_length;
481 >        nw_uint32 dl_addr_offset;
482   };
483  
484   // Parameters for I_OTSetRawMode/kOTSetRecvMode ioctl()
485   struct dl_recv_control_t {
486 <        uint32 dl_primitive;
487 <        uint32 dl_flags;
488 <        uint32 dl_truncation_length;
486 >        nw_uint32 dl_primitive;
487 >        nw_uint32 dl_flags;
488 >        nw_uint32 dl_truncation_length;
489   };
490  
491   union DL_primitives {
492 <        uint32 dl_primitive;
492 >        nw_uint32 dl_primitive;
493          dl_info_req_t info_req;
494          dl_info_ack_t info_ack;
495          dl_bind_req_t bind_req;
# Line 410 | Line 516 | union DL_primitives {
516   struct EnetPacketHeader {
517          uint8 fDestAddr[6];
518          uint8 fSourceAddr[6];
519 <        uint16 fProto;
519 >        nw_uint16 fProto;
520   } PACKED__;
521  
522   struct T8022Header {
# Line 433 | Line 539 | struct T8022FullPacketHeader {
539  
540   struct T8022AddressStruct {
541          uint8 fHWAddr[6];
542 <        uint16 fSAP;
542 >        nw_uint16 fSAP;
543          uint8 fSNAP[k8022SNAPLength];
544   } PACKED__;
545  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines