Annotation of Gnu-Mach/linux/pcmcia-cs/glue/wireless_glue.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * wireless network glue code
                      3:  *
                      4:  * Copyright (C) 2006 Free Software Foundation, Inc.
                      5:  * Written by Stefan Siegl <[email protected]>.
                      6:  *
                      7:  * This file is part of GNU Mach.
                      8:  *
                      9:  * This program is free software; you can redistribute it and/or modify
                     10:  * it under the terms of the GNU General Public License as published by
                     11:  * the Free Software Foundation; either version 2, or (at your option)
                     12:  * any later version.
                     13:  *
                     14:  * This program is distributed in the hope that it will be useful,
                     15:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17:  * GNU General Public License for more details.
                     18:  *
                     19:  * You should have received a copy of the GNU General Public License
                     20:  * along with this program; if not, write to the Free Software
                     21:  * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
                     22:  */
                     23: 
                     24: #ifndef _WIRELESS_GLUE_H
                     25: #define _WIRELESS_GLUE_H
                     26: 
                     27: /*
                     28:  * Wireless glue configuration.
                     29:  */
                     30: 
                     31: /*
                     32:  * Include the pcmcia glue as well, in case the kernel is configured for
                     33:  * it.
                     34:  */
                     35: #ifdef CONFIG_PCMCIA
                     36: #define PCMCIA_CLIENT
                     37: #include "pcmcia_glue.h"
                     38: #endif
                     39: 
                     40: 
                     41: /*
                     42:  * Definition of a `BUG' function: write message and panic out.
                     43:  */
                     44: #ifndef BUG
                     45: #define BUG() \
                     46:   do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
                     47:     *(int *)0=0; } while (0)
                     48: #endif
                     49: 
                     50: 
                     51: #include <kern/debug.h>
                     52: 
                     53: /*
                     54:  * We need some `schedule_task' replacement.  This is defined in
                     55:  * kernel/context.c in the Linux kernel.
                     56:  */
                     57: static inline int
                     58: schedule_task(struct tq_struct *task)
                     59: {
                     60:   printk(KERN_INFO "schedule_task: not implemented, task=%p\n", task);
                     61:   Debugger("schedule_task");
                     62:   return 0; /* fail */
                     63: }
                     64: 
                     65: 
                     66: /*
                     67:  * min() and max() macros that also do strict type-checking.  See the
                     68:  * "unnecessary" pointer comparison.
                     69:  */
                     70: #define min(x,y) ({ \
                     71:         const typeof(x) _x = (x);       \
                     72:         const typeof(y) _y = (y);       \
                     73:         (void) (&_x == &_y);            \
                     74:         _x < _y ? _x : _y; })
                     75: 
                     76: #define max(x,y) ({ \
                     77:         const typeof(x) _x = (x);       \
                     78:         const typeof(y) _y = (y);       \
                     79:         (void) (&_x == &_y);            \
                     80:         _x > _y ? _x : _y; })
                     81: 
                     82: /*
                     83:  * ... and if you can't take the strict types, you can specify one
                     84:  * yourself.
                     85:  */
                     86: #define min_t(type,x,y) \
                     87:         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
                     88: #define max_t(type,x,y) \
                     89:         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
                     90: 
                     91: 
                     92: #define DEV_KFREE_SKB(skb)      dev_kfree_skb(skb, FREE_WRITE)
                     93: 
                     94: 
                     95: /*
                     96:  * TODO: this is i386 specific.
                     97:  */
                     98: #define le16_to_cpus(x)  do { } while(0)
                     99: 
                    100: 
                    101: /*
                    102:  * Some wireless drivers check for a return value from `copy_to_user',
                    103:  * however the `memcpy_tofs' implementation does return void.
                    104:  */
                    105: #undef copy_to_user
                    106: #define copy_to_user(a,b,c)    ((memcpy_tofs(a,b,c)), 0)
                    107: 
                    108: 
                    109: /*
                    110:  * Some more macros that are available on 2.2 and 2.4 Linux kernels.
                    111:  */
                    112: #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
                    113: 
                    114: 
                    115: /*
                    116:  * TQUEUE glue.
                    117:  */
                    118: #define PREPARE_TQUEUE(_tq, _routine, _data)                    \
                    119:   do {                                                          \
                    120:     (_tq)->routine = _routine;                                  \
                    121:     (_tq)->data = _data;                                       \
                    122:   } while (0)
                    123: #define INIT_TQUEUE(_tq, _routine, _data)                       \
                    124:   do {                                                         \
                    125:     (_tq)->next = 0;                                           \
                    126:     (_tq)->sync = 0;                                           \
                    127:     PREPARE_TQUEUE((_tq), (_routine), (_data));                        \
                    128:   } while (0)
                    129: 
                    130: 
                    131: /*
                    132:  * `etherdev' allocator.
                    133:  */
                    134: static inline struct net_device *
                    135: alloc_etherdev(int sz)
                    136: {
                    137:   struct net_device *dev;
                    138:   sz += sizeof(*dev) + 31;
                    139: 
                    140:   if (!(dev = kmalloc(sz, GFP_KERNEL)))
                    141:     return NULL;
                    142:   memset(dev, 0, sz);
                    143: 
                    144:   if (sz)
                    145:     dev->priv = (void *)(((long)dev + sizeof(*dev) + 31) & ~31);
                    146: 
                    147:   /* just allocate some space for the device name,
                    148:    * register_netdev will happily provide one to us 
                    149:    */
                    150:   dev->name = kmalloc(8, GFP_KERNEL);
                    151:   dev->name[0] = 0;
                    152: 
                    153:   ether_setup(dev);
                    154:   return dev;
                    155: }
                    156: 
                    157: 
                    158: #endif /* _WIRELESS_GLUE_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.