source: sbliveos2/trunk/lib32/misc.c@ 151

Last change on this file since 151 was 151, checked in by sandervl, 25 years ago

update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/* $Id: misc.c 151 2000-05-28 16:50:46Z sandervl $ */
2
3//******************************************************************************
4// OS/2 implementation of misc. Linux kernel services
5//
6// Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
7//
8// Parts based on Linux kernel code (set/clear_bit)
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 "hwaccess.h"
27#include <linux/init.h>
28#include <linux/poll.h>
29#include <asm/uaccess.h>
30#include <asm/hardirq.h>
31#include <linux\ioport.h>
32#include <linux\utsname.h>
33
34struct new_utsname system_utsname = {0};
35struct resource ioport_resource = {0};
36mem_map_t *mem_map = 0;
37
38void set_bit(int nr, volatile void * addr)
39{
40 volatile unsigned long *pAddr = (volatile unsigned long *)addr;
41
42 *pAddr = (*pAddr) | (1 << nr);
43}
44
45void clear_bit(int nr, volatile void * addr)
46{
47 volatile unsigned long *pAddr = (volatile unsigned long *)addr;
48
49 *pAddr = (*pAddr) & ~(1 << nr);
50}
51
52#define CR 0x0d
53#define LF 0x0a
54
55
56#define LEADING_ZEROES 0x8000
57#define SIGNIFICANT_FIELD 0x0007
58
59char *HexLongToASCII(char *StrPtr, unsigned long wHexVal, unsigned short Option);
60char *DecLongToASCII(char *StrPtr, unsigned long lDecVal, unsigned short Option);
61
62
63//SvL: Not safe to use in non-KEE driver
64int sprintf (char *buffer, const char *format, ...)
65{
66 char *BuildPtr=buffer;
67 char *pStr = (char *) format;
68 char *SubStr;
69 union {
70 void *VoidPtr;
71 unsigned short *WordPtr;
72 unsigned long *LongPtr;
73#ifdef KEE
74 unsigned long *StringPtr;
75#else
76 double *StringPtr;
77#endif
78 } Parm;
79 int wBuildOption;
80
81 Parm.VoidPtr=(void *) &format;
82 Parm.StringPtr++; // skip size of string pointer
83
84 while (*pStr)
85 {
86 switch (*pStr)
87 {
88 case '%':
89 wBuildOption=0;
90 pStr++;
91 if (*pStr=='0')
92 {
93 wBuildOption|=LEADING_ZEROES;
94 pStr++;
95 }
96 if (*pStr=='u') // always unsigned
97 pStr++;
98
99 switch(*pStr)
100 {
101 case 'x':
102 case 'X':
103 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);
104 pStr++;
105 continue;
106
107 case 'd':
108 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);
109 pStr++;
110 continue;
111
112#ifdef KEE
113 case 's':
114 SubStr=(char *)*Parm.StringPtr;
115 while (*BuildPtr++ = *SubStr++);
116 Parm.StringPtr++;
117 BuildPtr--; // remove the \0
118 pStr++;
119 continue;
120#endif
121 case 'l':
122 pStr++;
123 switch (*pStr)
124 {
125 case 'x':
126 case 'X':
127 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);
128 pStr++;
129 continue;
130
131 case 'd':
132 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);
133 pStr++;
134 continue;
135 } // end switch
136 continue; // dunno what he wants
137
138 case 0:
139 continue;
140 } // end switch
141 break;
142
143 case '\\':
144 pStr++;
145 switch (*pStr)
146 {
147 case 'n':
148 *BuildPtr++=LF;
149 pStr++;
150 continue;
151
152 case 'r':
153 *BuildPtr++=CR;
154 pStr++;
155 continue;
156
157 case 0:
158 continue;
159 break;
160 } // end switch
161
162 break;
163 } // end switch
164
165 *BuildPtr++=*pStr++;
166 } // end while
167
168 *BuildPtr=0; // cauterize the string
169 return 1; //not correct
170}
171
172int printk(const char * fmt, ...)
173{
174 return 0;
175}
176
177void schedule(void)
178{
179
180}
181
182void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
183{
184
185}
186
187
188int __check_region(struct resource *a, unsigned long b, unsigned long c)
189{
190 return 0;
191}
192
193void __release_region(struct resource *a, unsigned long b, unsigned long c)
194{
195
196}
197
198struct resource * __request_region(struct resource *a, unsigned long start, unsigned long n, const char *name)
199{
200 return a;
201}
202
203void iodelay32(unsigned long);
204#pragma aux iodelay32 parm nomemory [eax] modify nomemory exact [eax ecx];
205
206void __udelay(unsigned long usecs)
207{
208 iodelay32(usecs*2);
209}
210
211
Note: See TracBrowser for help on using the repository browser.