source: GPL/trunk/lib32/misc.c@ 347

Last change on this file since 347 was 347, checked in by Brendan Oakley, 17 years ago

Adjustments to linux headers and lib32 for compiling resync 1.0.4

File size: 8.4 KB
Line 
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
41struct new_utsname system_utsname = {0};
42struct resource ioport_resource = {NULL, 0, 0, IORESOURCE_IO, NULL, NULL, NULL};
43struct resource iomem_resource = {NULL, 0, 0, IORESOURCE_MEM, NULL, NULL, NULL};
44mem_map_t *mem_map = 0;
45int this_module[64] = {0};
46
47#include <stdarg.h>
48
49char szLastALSAError1[128] = {0};
50char szOverrunTest1 = 0xCC;
51char szLastALSAError2[128] = {0};
52char szOverrunTest2 = 0xCC;
53int 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//******************************************************************************
59int 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//******************************************************************************
84void schedule(void)
85{
86
87}
88//******************************************************************************
89//******************************************************************************
90void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
91{
92
93}
94//******************************************************************************
95//******************************************************************************
96int __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
112unsigned 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//******************************************************************************
122pgprot_t __pgprot(int x)
123{
124 unsigned long long cast_x;
125 pgprot_t pg;
126 cast_x = (unsigned long long) (x);
127 pg.pgprot = cast_x;
128 return (pg);
129}
130//******************************************************************************
131//******************************************************************************
132struct proc_dir_entry proc_root = {0};
133//******************************************************************************
134//******************************************************************************
135struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
136 struct proc_dir_entry *parent)
137{
138 struct proc_dir_entry *proc;
139
140 proc = (struct proc_dir_entry *)kmalloc(sizeof(struct proc_dir_entry), 0);
141 memset(proc, 0, sizeof(struct proc_dir_entry));
142
143 proc->name = name;
144 proc->mode = mode;
145 proc->parent = parent;
146
147 return proc;
148}
149//******************************************************************************
150//******************************************************************************
151void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
152{
153 return; //memory leak
154}
155//******************************************************************************
156//******************************************************************************
157int proc_register(struct proc_dir_entry *parent, struct proc_dir_entry *proc)
158{
159 return 0;
160}
161//******************************************************************************
162//******************************************************************************
163int proc_unregister(struct proc_dir_entry *proc, int bla)
164{
165 return 0;
166}
167//******************************************************************************
168//******************************************************************************
169int fasync_helper(int a, struct file *b, int c, struct fasync_struct **d)
170{
171 return 0;
172}
173//******************************************************************************
174//******************************************************************************
175void kill_fasync(struct fasync_struct *a, int b, int c)
176{
177}
178//******************************************************************************
179//******************************************************************************
180int request_dma(unsigned int dmanr, const char * device_id) /* reserve a DMA channel */
181{
182 DebugInt3();
183 return 0;
184}
185//******************************************************************************
186//******************************************************************************
187void free_dma(unsigned int dmanr)
188{
189 DebugInt3();
190}
191//******************************************************************************
192/* enable/disable a specific DMA channel */
193//******************************************************************************
194void enable_dma(unsigned int dmanr)
195{
196 DebugInt3();
197}
198//******************************************************************************
199//******************************************************************************
200void disable_dma(unsigned int dmanr)
201{
202 DebugInt3();
203}
204//******************************************************************************
205static struct notifier_block *reboot_notify_list = NULL;
206// No need to implement this right now. The ESS Maestro 3 driver uses it
207// to call pci_unregister_driver, which is always called from the shutdown
208// notification sent by OS2.
209// Same goes for es1968 & Yamaha's DS1/DS1E.
210//******************************************************************************
211int register_reboot_notifier(struct notifier_block *pnblock)
212{
213 return 0;
214}
215//******************************************************************************
216//******************************************************************************
217int unregister_reboot_notifier(struct notifier_block *pnblock)
218{
219 return 0;
220}
221//******************************************************************************
222//******************************************************************************
223void *snd_compat_kcalloc(size_t n, size_t size, int flags)
224{
225 void *ret = NULL;
226
227 if (n != 0 && size > INT_MAX / n)
228 return ret;
229
230 ret = kmalloc(n * size, flags);
231 if (ret)
232 memset(ret, 0, n * size);
233 return ret;
234}
235
Note: See TracBrowser for help on using the repository browser.