| 1 | /* $Id: misc.c,v 1.1.1.1 2003/07/02 13:57:02 eleph Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * OS/2 implementation of misc. Linux kernel services | 
|---|
| 4 | * | 
|---|
| 5 | * (C) 2000-2002 InnoTek Systemberatung GmbH | 
|---|
| 6 | * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 7 | * | 
|---|
| 8 | * hweight32 based on Linux code (bitops.h) | 
|---|
| 9 | * | 
|---|
| 10 | * This program is free software; you can redistribute it and/or | 
|---|
| 11 | * modify it under the terms of the GNU General Public License as | 
|---|
| 12 | * published by the Free Software Foundation; either version 2 of | 
|---|
| 13 | * the License, or (at your option) any later version. | 
|---|
| 14 | * | 
|---|
| 15 | * This program is distributed in the hope that it will be useful, | 
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 18 | * GNU General Public License for more details. | 
|---|
| 19 | * | 
|---|
| 20 | * You should have received a copy of the GNU General Public | 
|---|
| 21 | * License along with this program; if not, write to the Free | 
|---|
| 22 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, | 
|---|
| 23 | * USA. | 
|---|
| 24 | * | 
|---|
| 25 | */ | 
|---|
| 26 | #include <limits.h> | 
|---|
| 27 | #include "linux.h" | 
|---|
| 28 | #include <linux/init.h> | 
|---|
| 29 | #include <linux/fs.h> | 
|---|
| 30 | #include <linux/poll.h> | 
|---|
| 31 | #define CONFIG_PROC_FS | 
|---|
| 32 | #include <linux/proc_fs.h> | 
|---|
| 33 | #include <asm/uaccess.h> | 
|---|
| 34 | #include <asm/hardirq.h> | 
|---|
| 35 | #include <linux\ioport.h> | 
|---|
| 36 | #include <linux\utsname.h> | 
|---|
| 37 | #include <linux\module.h> | 
|---|
| 38 | #include <dbgos2.h> | 
|---|
| 39 | #include <printfos2.h> | 
|---|
| 40 |  | 
|---|
| 41 | struct new_utsname system_utsname = {0}; | 
|---|
| 42 | struct resource ioport_resource = {NULL, 0, 0, IORESOURCE_IO, NULL, NULL, NULL}; | 
|---|
| 43 | struct resource iomem_resource  = {NULL, 0, 0, IORESOURCE_MEM, NULL, NULL, NULL}; | 
|---|
| 44 | mem_map_t *mem_map = 0; | 
|---|
| 45 | int this_module[64] = {0}; | 
|---|
| 46 |  | 
|---|
| 47 | #include <stdarg.h> | 
|---|
| 48 |  | 
|---|
| 49 | char szLastALSAError1[128] = {0}; | 
|---|
| 50 | char szOverrunTest1        = 0xCC; | 
|---|
| 51 | char szLastALSAError2[128] = {0}; | 
|---|
| 52 | char szOverrunTest2        = 0xCC; | 
|---|
| 53 | int  iLastError            = 0; | 
|---|
| 54 |  | 
|---|
| 55 | //****************************************************************************** | 
|---|
| 56 | //Save error message in szLastALSAError; if card init failed, then we will | 
|---|
| 57 | //print it in drv32\init.cpp | 
|---|
| 58 | //****************************************************************************** | 
|---|
| 59 | int printk(const char * fmt, ...) | 
|---|
| 60 | { | 
|---|
| 61 | va_list argptr;                /* -> variable argument list */ | 
|---|
| 62 |  | 
|---|
| 63 | char *pszLastALSAError; | 
|---|
| 64 |  | 
|---|
| 65 | pszLastALSAError= iLastError ? szLastALSAError2 : szLastALSAError1; | 
|---|
| 66 |  | 
|---|
| 67 | va_start(argptr, fmt);           /* get pointer to argument list */ | 
|---|
| 68 | vsprintf(pszLastALSAError, fmt, argptr); | 
|---|
| 69 | //    strcat(pszLastALSAError, "\r"); | 
|---|
| 70 | va_end(argptr);                /* done with variable arguments */ | 
|---|
| 71 |  | 
|---|
| 72 | if(szOverrunTest1 != 0xCC || szOverrunTest2 != 0xCC) { | 
|---|
| 73 | DebugInt3(); | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | dprintf( (pszLastALSAError) ); | 
|---|
| 77 | if(++iLastError > 1) { | 
|---|
| 78 | iLastError = 0; | 
|---|
| 79 | } | 
|---|
| 80 | return 0; | 
|---|
| 81 | } | 
|---|
| 82 | //****************************************************************************** | 
|---|
| 83 | //****************************************************************************** | 
|---|
| 84 | void schedule(void) | 
|---|
| 85 | { | 
|---|
| 86 |  | 
|---|
| 87 | } | 
|---|
| 88 | //****************************************************************************** | 
|---|
| 89 | //****************************************************************************** | 
|---|
| 90 | void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) | 
|---|
| 91 | { | 
|---|
| 92 |  | 
|---|
| 93 | } | 
|---|
| 94 | //****************************************************************************** | 
|---|
| 95 | //****************************************************************************** | 
|---|
| 96 | int __check_region(struct resource *a, unsigned long b, unsigned long c) | 
|---|
| 97 | { | 
|---|
| 98 | DebugInt3(); | 
|---|
| 99 | return 0; | 
|---|
| 100 | } | 
|---|
| 101 |  | 
|---|
| 102 | /* --------------------------------------------------------------------- */ | 
|---|
| 103 | /* | 
|---|
| 104 | * hweightN: returns the hamming weight (i.e. the number | 
|---|
| 105 | * of bits set) of a N-bit word | 
|---|
| 106 | */ | 
|---|
| 107 |  | 
|---|
| 108 | #ifdef hweight32 | 
|---|
| 109 | #undef hweight32 | 
|---|
| 110 | #endif | 
|---|
| 111 |  | 
|---|
| 112 | unsigned int hweight32(unsigned int w) | 
|---|
| 113 | { | 
|---|
| 114 | unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555); | 
|---|
| 115 | res = (res & 0x33333333) + ((res >> 2) & 0x33333333); | 
|---|
| 116 | res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); | 
|---|
| 117 | res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); | 
|---|
| 118 | return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF); | 
|---|
| 119 | } | 
|---|
| 120 | //****************************************************************************** | 
|---|
| 121 | //****************************************************************************** | 
|---|
| 122 | mem_map_t *virt_to_page(int x) | 
|---|
| 123 | { | 
|---|
| 124 | static mem_map_t map = {0}; | 
|---|
| 125 | return ↦ | 
|---|
| 126 | } | 
|---|
| 127 | //****************************************************************************** | 
|---|
| 128 | //****************************************************************************** | 
|---|
| 129 | struct proc_dir_entry proc_root = {0}; | 
|---|
| 130 | //****************************************************************************** | 
|---|
| 131 | //****************************************************************************** | 
|---|
| 132 | struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, | 
|---|
| 133 | struct proc_dir_entry *parent) | 
|---|
| 134 | { | 
|---|
| 135 | struct proc_dir_entry *proc; | 
|---|
| 136 |  | 
|---|
| 137 | proc = (struct proc_dir_entry *)kmalloc(sizeof(struct proc_dir_entry), 0); | 
|---|
| 138 | memset(proc, 0, sizeof(struct proc_dir_entry)); | 
|---|
| 139 |  | 
|---|
| 140 | proc->name   = name; | 
|---|
| 141 | proc->mode   = mode; | 
|---|
| 142 | proc->parent = parent; | 
|---|
| 143 |  | 
|---|
| 144 | return proc; | 
|---|
| 145 | } | 
|---|
| 146 | //****************************************************************************** | 
|---|
| 147 | //****************************************************************************** | 
|---|
| 148 | void remove_proc_entry(const char *name, struct proc_dir_entry *parent) | 
|---|
| 149 | { | 
|---|
| 150 | return; //memory leak | 
|---|
| 151 | } | 
|---|
| 152 | //****************************************************************************** | 
|---|
| 153 | //****************************************************************************** | 
|---|
| 154 | int proc_register(struct proc_dir_entry *parent, struct proc_dir_entry *proc) | 
|---|
| 155 | { | 
|---|
| 156 | return 0; | 
|---|
| 157 | } | 
|---|
| 158 | //****************************************************************************** | 
|---|
| 159 | //****************************************************************************** | 
|---|
| 160 | int proc_unregister(struct proc_dir_entry *proc, int bla) | 
|---|
| 161 | { | 
|---|
| 162 | return 0; | 
|---|
| 163 | } | 
|---|
| 164 | //****************************************************************************** | 
|---|
| 165 | //****************************************************************************** | 
|---|
| 166 | int fasync_helper(int a, struct file *b, int c, struct fasync_struct **d) | 
|---|
| 167 | { | 
|---|
| 168 | return 0; | 
|---|
| 169 | } | 
|---|
| 170 | //****************************************************************************** | 
|---|
| 171 | //****************************************************************************** | 
|---|
| 172 | void kill_fasync(struct fasync_struct *a, int b, int c) | 
|---|
| 173 | { | 
|---|
| 174 | } | 
|---|
| 175 | //****************************************************************************** | 
|---|
| 176 | //****************************************************************************** | 
|---|
| 177 | int request_dma(unsigned int dmanr, const char * device_id)     /* reserve a DMA channel */ | 
|---|
| 178 | { | 
|---|
| 179 | DebugInt3(); | 
|---|
| 180 | return 0; | 
|---|
| 181 | } | 
|---|
| 182 | //****************************************************************************** | 
|---|
| 183 | //****************************************************************************** | 
|---|
| 184 | void free_dma(unsigned int dmanr) | 
|---|
| 185 | { | 
|---|
| 186 | DebugInt3(); | 
|---|
| 187 | } | 
|---|
| 188 | //****************************************************************************** | 
|---|
| 189 | /* enable/disable a specific DMA channel */ | 
|---|
| 190 | //****************************************************************************** | 
|---|
| 191 | void enable_dma(unsigned int dmanr) | 
|---|
| 192 | { | 
|---|
| 193 | DebugInt3(); | 
|---|
| 194 | } | 
|---|
| 195 | //****************************************************************************** | 
|---|
| 196 | //****************************************************************************** | 
|---|
| 197 | void disable_dma(unsigned int dmanr) | 
|---|
| 198 | { | 
|---|
| 199 | DebugInt3(); | 
|---|
| 200 | } | 
|---|
| 201 | //****************************************************************************** | 
|---|
| 202 | static struct notifier_block *reboot_notify_list = NULL; | 
|---|
| 203 | // No need to implement this right now. The ESS Maestro 3 driver uses it | 
|---|
| 204 | // to call pci_unregister_driver, which is always called from the shutdown | 
|---|
| 205 | // notification sent by OS2. | 
|---|
| 206 | // Same goes for es1968 & Yamaha's DS1/DS1E. | 
|---|
| 207 | //****************************************************************************** | 
|---|
| 208 | int register_reboot_notifier(struct notifier_block *pnblock) | 
|---|
| 209 | { | 
|---|
| 210 | return 0; | 
|---|
| 211 | } | 
|---|
| 212 | //****************************************************************************** | 
|---|
| 213 | //****************************************************************************** | 
|---|
| 214 | int unregister_reboot_notifier(struct notifier_block *pnblock) | 
|---|
| 215 | { | 
|---|
| 216 | return 0; | 
|---|
| 217 | } | 
|---|
| 218 | //****************************************************************************** | 
|---|
| 219 | //****************************************************************************** | 
|---|
| 220 | void *snd_compat_kcalloc(size_t n, size_t size, int flags) | 
|---|
| 221 | { | 
|---|
| 222 | void *ret = NULL; | 
|---|
| 223 |  | 
|---|
| 224 | if (n != 0 && size > INT_MAX / n) | 
|---|
| 225 | return ret; | 
|---|
| 226 |  | 
|---|
| 227 | ret = kmalloc(n * size, flags); | 
|---|
| 228 | if (ret) | 
|---|
| 229 | memset(ret, 0, n * size); | 
|---|
| 230 | return ret; | 
|---|
| 231 | } | 
|---|
| 232 |  | 
|---|