authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-14 07:12:04+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-14 08:25:08+02:00
log234630bb8d891b090e29841a2e7b4b56a596dba1
treea25f5cecd38eb1687f73865d0420975aae4f92ce
parent007cc817a1b366c6472bab20919d6bb9ecf6e055
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

netbsd: add some missing system headers

The Lua headers are needed because, yes, NetBSD has a kernel module for Lua support. soundcard.h is technically a system header but is installed by libossaudio and so was missed previously. This also removes some riscv headers that shouldn't have been added because NetBSD does not yet officially support the riscv32/riscv64 ports. Closes #24737.

64 files changed, 3290 insertions(+), 3792 deletions(-)

lib/libc/include/arm-netbsd-eabi/machine/byte_swap.h deleted-121
......@@ -1,121 +0,0 @@
1/* $NetBSD: byte_swap.h,v 1.16 2017/01/17 11:08:50 rin Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum, Neil A. Carson, and Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _ARM_BYTE_SWAP_H_
33#define _ARM_BYTE_SWAP_H_
34
35#ifdef _LOCORE
36
37#if defined(_ARM_ARCH_6) || defined(_ARM_ARCH_7)
38
39#define BSWAP16(_src, _dst, _tmp) \
40 rev16 _dst, _src
41#define BSWAP32(_src, _dst, _tmp) \
42 rev _dst, _src
43
44#else
45
46#define BSWAP16(_src, _dst, _tmp) \
47 mov _tmp, _src, ror #8 ;\
48 orr _tmp, _tmp, _tmp, lsr #16 ;\
49 bic _dst, _tmp, _tmp, lsl #16
50
51#define BSWAP32(_src, _dst, _tmp) \
52 eor _tmp, _src, _src, ror #16 ;\
53 bic _tmp, _tmp, #0x00FF0000 ;\
54 mov _dst, _src, ror #8 ;\
55 eor _dst, _dst, _tmp, lsr #8
56
57#endif
58
59
60#else
61
62#ifdef __GNUC__
63#include <sys/types.h>
64__BEGIN_DECLS
65
66#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
67static __inline uint32_t
68__byte_swap_u32_variable(uint32_t v)
69{
70 uint32_t t1;
71
72#ifdef _ARM_ARCH_6
73 if (!__builtin_constant_p(v)) {
74 __asm("rev\t%0, %1" : "=r" (v) : "0" (v));
75 return v;
76 }
77#endif
78
79 t1 = v ^ ((v << 16) | (v >> 16));
80 t1 &= 0xff00ffffU;
81 v = (v >> 8) | (v << 24);
82 v ^= (t1 >> 8);
83
84 return v;
85}
86
87#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable
88static __inline uint16_t
89__byte_swap_u16_variable(uint16_t v)
90{
91
92#ifdef _ARM_ARCH_6
93 if (!__builtin_constant_p(v)) {
94 uint32_t v32 = v;
95 __asm("rev16\t%0, %1" : "=r" (v32) : "0" (v32));
96 return (uint16_t)v32;
97 }
98#elif !defined(__thumb__) && 0 /* gcc produces decent code for this */
99 if (!__builtin_constant_p(v)) {
100 uint32_t v0 = v;
101 __asm volatile(
102 "mov %0, %1, ror #8\n"
103 "orr %0, %0, %0, lsr #16\n"
104 "bic %0, %0, %0, lsl #16"
105 : "=&r" (v0)
106 : "0" (v0));
107 return (uint16_t)v0;
108 }
109#endif
110 v &= 0xffff;
111 v = (uint16_t)((v >> 8) | (v << 8));
112
113 return v;
114}
115
116__END_DECLS
117#endif
118
119#endif /* _LOCORE */
120
121#endif /* _ARM_BYTE_SWAP_H_ */
\ No newline at end of file
lib/libc/include/arm-netbsd-eabi/machine/sysarch.h deleted-85
......@@ -1,85 +0,0 @@
1/* $NetBSD: sysarch.h,v 1.15 2021/10/06 05:33:15 skrll Exp $ */
2
3/*
4 * Copyright (c) 1996-1997 Mark Brinicombe.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Mark Brinicombe.
18 * 4. The name of the company nor the name of the author may be used to
19 * endorse or promote products derived from this software without specific
20 * prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#ifndef _ARM_SYSARCH_H_
36#define _ARM_SYSARCH_H_
37
38#include <sys/cdefs.h>
39
40/*
41 * Pickup definition of size_t and uintptr_t
42 */
43#include <machine/ansi.h>
44#include <sys/stdint.h>
45#ifndef _KERNEL
46#include <stdbool.h>
47#endif
48
49#ifdef _BSD_SIZE_T_
50typedef _BSD_SIZE_T_ size_t;
51#undef _BSD_SIZE_T_
52#endif
53
54/*
55 * Architecture specific syscalls (arm)
56 */
57
58#define ARM_SYNC_ICACHE 0
59#define ARM_DRAIN_WRITEBUF 1
60#define ARM_VFP_FPSCR 2
61#define ARM_FPU_USED 3
62
63struct arm_sync_icache_args {
64 uintptr_t addr; /* Virtual start address */
65 size_t len; /* Region size */
66};
67
68struct arm_vfp_fpscr_args {
69 uint32_t fpscr_clear; /* bits to clear */
70 uint32_t fpscr_set; /* bits to set */
71};
72
73struct arm_unaligned_faults_args {
74 bool enabled; /* unaligned faults are enabled */
75};
76
77#ifndef _KERNEL
78__BEGIN_DECLS
79int arm_sync_icache(uintptr_t, size_t);
80int arm_drain_writebuf(void);
81int sysarch(int, void *);
82__END_DECLS
83#endif
84
85#endif /* !_ARM_SYSARCH_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/lauxlib.h created+319
......@@ -0,0 +1,319 @@
1/* $NetBSD: lauxlib.h,v 1.8.10.1 2023/08/11 16:22:06 martin Exp $ */
2
3/*
4** Id: lauxlib.h
5** Auxiliary functions for building Lua libraries
6** See Copyright Notice in lua.h
7*/
8
9
10#ifndef lauxlib_h
11#define lauxlib_h
12
13
14#ifndef _KERNEL
15#include <stddef.h>
16#include <stdio.h>
17#endif /* _KERNEL */
18
19#include "luaconf.h"
20#include "lua.h"
21
22
23/* global table */
24#define LUA_GNAME "_G"
25
26
27typedef struct luaL_Buffer luaL_Buffer;
28
29
30/* extra error code for 'luaL_loadfilex' */
31#define LUA_ERRFILE (LUA_ERRERR+1)
32
33
34/* key, in the registry, for table of loaded modules */
35#define LUA_LOADED_TABLE "_LOADED"
36
37
38/* key, in the registry, for table of preloaded loaders */
39#define LUA_PRELOAD_TABLE "_PRELOAD"
40
41
42typedef struct luaL_Reg {
43 const char *name;
44 lua_CFunction func;
45} luaL_Reg;
46
47
48#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number))
49
50LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);
51#define luaL_checkversion(L) \
52 luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
53
54LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
55LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
56LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
57LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
58LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname);
59LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
60 size_t *l);
61LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
62 const char *def, size_t *l);
63LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
64LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
65
66#ifndef _KERNEL
67LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
68LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
69 lua_Integer def);
70#else /* _KERNEL */
71#define luaL_checkinteger luaL_checknumber
72#define luaL_optinteger(L,a,d) luaL_optnumber(L, (a), (lua_Number)(d))
73#endif /* _KERNEL */
74
75LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
76LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
77LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
78
79LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
80LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
81LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
82LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
83
84LUALIB_API void (luaL_where) (lua_State *L, int lvl);
85LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
86
87LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
88 const char *const lst[]);
89
90#ifndef _KERNEL
91LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
92LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
93#endif /* _KERNEL */
94
95
96/* predefined references */
97#define LUA_NOREF (-2)
98#define LUA_REFNIL (-1)
99
100LUALIB_API int (luaL_ref) (lua_State *L, int t);
101LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
102
103#ifndef _KERNEL
104LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
105 const char *mode);
106
107#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL)
108#endif /* _KERNEL */
109
110LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
111 const char *name, const char *mode);
112LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
113
114LUALIB_API lua_State *(luaL_newstate) (void);
115
116LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
117
118LUALIB_API void (luaL_addgsub) (luaL_Buffer *b, const char *s,
119 const char *p, const char *r);
120LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s,
121 const char *p, const char *r);
122
123LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
124
125LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
126
127LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
128 const char *msg, int level);
129
130LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
131 lua_CFunction openf, int glb);
132
133/*
134** ===============================================================
135** some useful macros
136** ===============================================================
137*/
138
139
140#define luaL_newlibtable(L,l) \
141 lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
142
143#define luaL_newlib(L,l) \
144 (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
145
146#define luaL_argcheck(L, cond,arg,extramsg) \
147 ((void)(luai_likely(cond) || luaL_argerror(L, (arg), (extramsg))))
148
149#define luaL_argexpected(L,cond,arg,tname) \
150 ((void)(luai_likely(cond) || luaL_typeerror(L, (arg), (tname))))
151
152#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
153#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
154
155#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
156
157#ifndef _KERNEL
158#define luaL_dofile(L, fn) \
159 (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
160#endif /* _KERNEL */
161
162#define luaL_dostring(L, s) \
163 (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
164
165#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
166
167#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
168
169#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)
170
171
172/*
173** Perform arithmetic operations on lua_Integer values with wrap-around
174** semantics, as the Lua core does.
175*/
176#define luaL_intop(op,v1,v2) \
177 ((lua_Integer)((lua_Unsigned)(v1) op (lua_Unsigned)(v2)))
178
179
180/* push the value used to represent failure/error */
181#define luaL_pushfail(L) lua_pushnil(L)
182
183
184/*
185** Internal assertions for in-house debugging
186*/
187#if !defined(lua_assert)
188
189#if defined LUAI_ASSERT
190 #include <assert.h>
191 #define lua_assert(c) assert(c)
192#else
193 #define lua_assert(c) ((void)0)
194#endif
195
196#endif
197
198
199
200/*
201** {======================================================
202** Generic Buffer manipulation
203** =======================================================
204*/
205
206struct luaL_Buffer {
207 char *b; /* buffer address */
208 size_t size; /* buffer size */
209 size_t n; /* number of characters in buffer */
210 lua_State *L;
211 union {
212 LUAI_MAXALIGN; /* ensure maximum alignment for buffer */
213 char b[LUAL_BUFFERSIZE]; /* initial buffer */
214 } init;
215};
216
217
218#define luaL_bufflen(bf) ((bf)->n)
219#define luaL_buffaddr(bf) ((bf)->b)
220
221
222#define luaL_addchar(B,c) \
223 ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
224 ((B)->b[(B)->n++] = (c)))
225
226#define luaL_addsize(B,s) ((B)->n += (s))
227
228#define luaL_buffsub(B,s) ((B)->n -= (s))
229
230LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
231LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
232LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
233LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
234LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
235LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
236LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
237LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
238
239#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
240
241/* }====================================================== */
242
243
244
245#ifndef _KERNEL
246/*
247** {======================================================
248** File handles for IO library
249** =======================================================
250*/
251
252/*
253** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
254** initial structure 'luaL_Stream' (it may contain other fields
255** after that initial structure).
256*/
257
258#define LUA_FILEHANDLE "FILE*"
259
260
261typedef struct luaL_Stream {
262 FILE *f; /* stream (NULL for incompletely created streams) */
263 lua_CFunction closef; /* to close stream (NULL for closed streams) */
264} luaL_Stream;
265
266/* }====================================================== */
267#endif /* _KERNEL */
268
269
270#ifndef _KERNEL
271/*
272** {==================================================================
273** "Abstraction Layer" for basic report of messages and errors
274** ===================================================================
275*/
276
277/* print a string */
278#if !defined(lua_writestring)
279#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
280#endif
281
282/* print a newline and flush the output */
283#if !defined(lua_writeline)
284#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
285#endif
286
287/* print an error message */
288#if !defined(lua_writestringerror)
289#define lua_writestringerror(s,p) \
290 (fprintf(stderr, (s), (p)), fflush(stderr))
291#endif
292
293/* }================================================================== */
294#endif /* _KERNEL */
295
296
297/*
298** {============================================================
299** Compatibility with deprecated conversions
300** =============================================================
301*/
302#if defined(LUA_COMPAT_APIINTCASTS)
303
304#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
305#define luaL_optunsigned(L,a,d) \
306 ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
307
308#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
309#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
310
311#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
312#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
313
314#endif
315/* }============================================================ */
316
317
318
319#endif
\ No newline at end of file
lib/libc/include/generic-netbsd/lua.h created+549
......@@ -0,0 +1,549 @@
1/* $NetBSD: lua.h,v 1.11.10.1 2023/08/11 16:22:07 martin Exp $ */
2
3/*
4** Id: lua.h
5** Lua - A Scripting Language
6** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
7** See Copyright Notice at the end of this file
8*/
9
10
11#ifndef lua_h
12#define lua_h
13
14#include <stdarg.h>
15#ifndef _KERNEL
16#include <stddef.h>
17#endif /* _KERNEL */
18
19
20#include "luaconf.h"
21
22
23#define LUA_VERSION_MAJOR "5"
24#define LUA_VERSION_MINOR "4"
25#define LUA_VERSION_RELEASE "6"
26
27#define LUA_VERSION_NUM 504
28#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 6)
29
30#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
31#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
32#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2023 Lua.org, PUC-Rio"
33#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
34
35
36/* mark for precompiled code ('<esc>Lua') */
37#define LUA_SIGNATURE "\x1bLua"
38
39/* option for multiple returns in 'lua_pcall' and 'lua_call' */
40#define LUA_MULTRET (-1)
41
42
43/*
44** Pseudo-indices
45** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty
46** space after that to help overflow detection)
47*/
48#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000)
49#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))
50
51
52/* thread status */
53#define LUA_OK 0
54#define LUA_YIELD 1
55#define LUA_ERRRUN 2
56#define LUA_ERRSYNTAX 3
57#define LUA_ERRMEM 4
58#define LUA_ERRERR 5
59
60
61typedef struct lua_State lua_State;
62
63
64/*
65** basic types
66*/
67#define LUA_TNONE (-1)
68
69#define LUA_TNIL 0
70#define LUA_TBOOLEAN 1
71#define LUA_TLIGHTUSERDATA 2
72#define LUA_TNUMBER 3
73#define LUA_TSTRING 4
74#define LUA_TTABLE 5
75#define LUA_TFUNCTION 6
76#define LUA_TUSERDATA 7
77#define LUA_TTHREAD 8
78
79#define LUA_NUMTYPES 9
80
81
82
83/* minimum Lua stack available to a C function */
84#define LUA_MINSTACK 20
85
86
87/* predefined values in the registry */
88#define LUA_RIDX_MAINTHREAD 1
89#define LUA_RIDX_GLOBALS 2
90#define LUA_RIDX_LAST LUA_RIDX_GLOBALS
91
92
93/* type of numbers in Lua */
94typedef LUA_NUMBER lua_Number;
95
96
97/* type for integer functions */
98typedef LUA_INTEGER lua_Integer;
99
100/* unsigned integer type */
101typedef LUA_UNSIGNED lua_Unsigned;
102
103/* type for continuation-function contexts */
104typedef LUA_KCONTEXT lua_KContext;
105
106
107/*
108** Type for C functions registered with Lua
109*/
110typedef int (*lua_CFunction) (lua_State *L);
111
112/*
113** Type for continuation functions
114*/
115typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
116
117
118/*
119** Type for functions that read/write blocks when loading/dumping Lua chunks
120*/
121typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
122
123typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
124
125
126/*
127** Type for memory-allocation functions
128*/
129typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
130
131
132/*
133** Type for warning functions
134*/
135typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);
136
137
138/*
139** Type used by the debug API to collect debug information
140*/
141typedef struct lua_Debug lua_Debug;
142
143
144/*
145** Functions to be called by the debugger in specific events
146*/
147typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
148
149
150/*
151** generic extra include file
152*/
153#if defined(LUA_USER_H)
154#include LUA_USER_H
155#endif
156
157
158/*
159** RCS ident string
160*/
161extern const char lua_ident[];
162
163
164/*
165** state manipulation
166*/
167LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
168LUA_API void (lua_close) (lua_State *L);
169LUA_API lua_State *(lua_newthread) (lua_State *L);
170LUA_API int (lua_closethread) (lua_State *L, lua_State *from);
171LUA_API int (lua_resetthread) (lua_State *L); /* Deprecated! */
172
173LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
174
175
176LUA_API lua_Number (lua_version) (lua_State *L);
177
178
179/*
180** basic stack manipulation
181*/
182LUA_API int (lua_absindex) (lua_State *L, int idx);
183LUA_API int (lua_gettop) (lua_State *L);
184LUA_API void (lua_settop) (lua_State *L, int idx);
185LUA_API void (lua_pushvalue) (lua_State *L, int idx);
186LUA_API void (lua_rotate) (lua_State *L, int idx, int n);
187LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx);
188LUA_API int (lua_checkstack) (lua_State *L, int n);
189
190LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
191
192
193/*
194** access functions (stack -> C)
195*/
196
197LUA_API int (lua_isnumber) (lua_State *L, int idx);
198LUA_API int (lua_isstring) (lua_State *L, int idx);
199LUA_API int (lua_iscfunction) (lua_State *L, int idx);
200LUA_API int (lua_isinteger) (lua_State *L, int idx);
201LUA_API int (lua_isuserdata) (lua_State *L, int idx);
202LUA_API int (lua_type) (lua_State *L, int idx);
203LUA_API const char *(lua_typename) (lua_State *L, int tp);
204
205#ifndef _KERNEL
206LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum);
207#else /* _KERNEL */
208#define lua_tonumberx (lua_Integer) lua_tointegerx
209#endif /* _KERNEL */
210LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum);
211LUA_API int (lua_toboolean) (lua_State *L, int idx);
212LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
213LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx);
214LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
215LUA_API void *(lua_touserdata) (lua_State *L, int idx);
216LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
217LUA_API const void *(lua_topointer) (lua_State *L, int idx);
218
219
220/*
221** Comparison and arithmetic functions
222*/
223
224#define LUA_OPADD 0 /* ORDER TM, ORDER OP */
225#define LUA_OPSUB 1
226#define LUA_OPMUL 2
227#define LUA_OPMOD 3
228#ifndef _KERNEL
229#define LUA_OPPOW 4
230#define LUA_OPDIV 5
231#define LUA_OPIDIV 6
232#define LUA_OPBAND 7
233#define LUA_OPBOR 8
234#define LUA_OPBXOR 9
235#define LUA_OPSHL 10
236#define LUA_OPSHR 11
237#define LUA_OPUNM 12
238#define LUA_OPBNOT 13
239#else /* _KERNEL */
240#define LUA_OPIDIV 4
241#define LUA_OPBAND 5
242#define LUA_OPBOR 6
243#define LUA_OPBXOR 7
244#define LUA_OPSHL 8
245#define LUA_OPSHR 9
246#define LUA_OPUNM 10
247#define LUA_OPBNOT 11
248#endif /* _KERNEL */
249
250LUA_API void (lua_arith) (lua_State *L, int op);
251
252#define LUA_OPEQ 0
253#define LUA_OPLT 1
254#define LUA_OPLE 2
255
256LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
257LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op);
258
259
260/*
261** push functions (C -> stack)
262*/
263LUA_API void (lua_pushnil) (lua_State *L);
264#ifndef _KERNEL
265LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
266#else /* _KERNEL */
267#define lua_pushnumber(L, n) lua_pushinteger(L, (lua_Integer)(n))
268#endif /* _KERNEL */
269LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
270LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);
271LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
272LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
273 va_list argp);
274LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
275LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
276LUA_API void (lua_pushboolean) (lua_State *L, int b);
277LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
278LUA_API int (lua_pushthread) (lua_State *L);
279
280
281/*
282** get functions (Lua -> stack)
283*/
284LUA_API int (lua_getglobal) (lua_State *L, const char *name);
285LUA_API int (lua_gettable) (lua_State *L, int idx);
286LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k);
287LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n);
288LUA_API int (lua_rawget) (lua_State *L, int idx);
289LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
290LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p);
291
292LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
293LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue);
294LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
295LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n);
296
297
298/*
299** set functions (stack -> Lua)
300*/
301LUA_API void (lua_setglobal) (lua_State *L, const char *name);
302LUA_API void (lua_settable) (lua_State *L, int idx);
303LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
304LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n);
305LUA_API void (lua_rawset) (lua_State *L, int idx);
306LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n);
307LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p);
308LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
309LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n);
310
311
312/*
313** 'load' and 'call' functions (load and run Lua code)
314*/
315LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults,
316 lua_KContext ctx, lua_KFunction k);
317#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL)
318
319LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
320 lua_KContext ctx, lua_KFunction k);
321#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)
322
323LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
324 const char *chunkname, const char *mode);
325
326LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);
327
328
329/*
330** coroutine functions
331*/
332LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx,
333 lua_KFunction k);
334LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg,
335 int *nres);
336LUA_API int (lua_status) (lua_State *L);
337LUA_API int (lua_isyieldable) (lua_State *L);
338
339#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)
340
341
342/*
343** Warning-related functions
344*/
345LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud);
346LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont);
347
348
349/*
350** garbage-collection function and options
351*/
352
353#define LUA_GCSTOP 0
354#define LUA_GCRESTART 1
355#define LUA_GCCOLLECT 2
356#define LUA_GCCOUNT 3
357#define LUA_GCCOUNTB 4
358#define LUA_GCSTEP 5
359#define LUA_GCSETPAUSE 6
360#define LUA_GCSETSTEPMUL 7
361#define LUA_GCISRUNNING 9
362#define LUA_GCGEN 10
363#define LUA_GCINC 11
364
365LUA_API int (lua_gc) (lua_State *L, int what, ...);
366
367
368/*
369** miscellaneous functions
370*/
371
372LUA_API int (lua_error) (lua_State *L);
373
374LUA_API int (lua_next) (lua_State *L, int idx);
375
376LUA_API void (lua_concat) (lua_State *L, int n);
377LUA_API void (lua_len) (lua_State *L, int idx);
378
379LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s);
380
381LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
382LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
383
384LUA_API void (lua_toclose) (lua_State *L, int idx);
385LUA_API void (lua_closeslot) (lua_State *L, int idx);
386
387
388/*
389** {==============================================================
390** some useful macros
391** ===============================================================
392*/
393
394#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE))
395
396#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL)
397#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL)
398
399#define lua_pop(L,n) lua_settop(L, -(n)-1)
400
401#define lua_newtable(L) lua_createtable(L, 0, 0)
402
403#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
404
405#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
406
407#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
408#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
409#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
410#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
411#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
412#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
413#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
414#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
415
416#define lua_pushliteral(L, s) lua_pushstring(L, "" s)
417
418#define lua_pushglobaltable(L) \
419 ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))
420
421#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
422
423
424#define lua_insert(L,idx) lua_rotate(L, (idx), 1)
425
426#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1))
427
428#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1))
429
430/* }============================================================== */
431
432
433/*
434** {==============================================================
435** compatibility macros
436** ===============================================================
437*/
438#if defined(LUA_COMPAT_APIINTCASTS)
439
440#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
441#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is))
442#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL)
443
444#endif
445
446#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1)
447#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1)
448#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1)
449
450#define LUA_NUMTAGS LUA_NUMTYPES
451
452/* }============================================================== */
453
454/*
455** {======================================================================
456** Debug API
457** =======================================================================
458*/
459
460
461/*
462** Event codes
463*/
464#define LUA_HOOKCALL 0
465#define LUA_HOOKRET 1
466#define LUA_HOOKLINE 2
467#define LUA_HOOKCOUNT 3
468#define LUA_HOOKTAILCALL 4
469
470
471/*
472** Event masks
473*/
474#define LUA_MASKCALL (1 << LUA_HOOKCALL)
475#define LUA_MASKRET (1 << LUA_HOOKRET)
476#define LUA_MASKLINE (1 << LUA_HOOKLINE)
477#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
478
479
480LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
481LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
482LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);
483LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);
484LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);
485LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);
486
487LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
488LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
489 int fidx2, int n2);
490
491LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
492LUA_API lua_Hook (lua_gethook) (lua_State *L);
493LUA_API int (lua_gethookmask) (lua_State *L);
494LUA_API int (lua_gethookcount) (lua_State *L);
495
496LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit);
497
498struct lua_Debug {
499 int event;
500 const char *name; /* (n) */
501 const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
502 const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
503 const char *source; /* (S) */
504 size_t srclen; /* (S) */
505 int currentline; /* (l) */
506 int linedefined; /* (S) */
507 int lastlinedefined; /* (S) */
508 unsigned char nups; /* (u) number of upvalues */
509 unsigned char nparams;/* (u) number of parameters */
510 char isvararg; /* (u) */
511 char istailcall; /* (t) */
512 unsigned short ftransfer; /* (r) index of first value transferred */
513 unsigned short ntransfer; /* (r) number of transferred values */
514 char short_src[LUA_IDSIZE]; /* (S) */
515 /* private part */
516 struct CallInfo *i_ci; /* active function */
517};
518
519/* }====================================================================== */
520
521
522/******************************************************************************
523#ifdef _KERNEL
524* Copyright (c) 2016-2017, Lourival Vieira Neto <lneto@NetBSD.org>.
525#endif
526* Copyright (C) 1994-2023 Lua.org, PUC-Rio.
527*
528* Permission is hereby granted, free of charge, to any person obtaining
529* a copy of this software and associated documentation files (the
530* "Software"), to deal in the Software without restriction, including
531* without limitation the rights to use, copy, modify, merge, publish,
532* distribute, sublicense, and/or sell copies of the Software, and to
533* permit persons to whom the Software is furnished to do so, subject to
534* the following conditions:
535*
536* The above copyright notice and this permission notice shall be
537* included in all copies or substantial portions of the Software.
538*
539* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
540* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
541* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
542* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
543* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
544* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
545* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
546******************************************************************************/
547
548
549#endif
\ No newline at end of file
lib/libc/include/generic-netbsd/luaconf.h created+873
......@@ -0,0 +1,873 @@
1/* $NetBSD: luaconf.h,v 1.23.10.1 2023/08/11 16:22:07 martin Exp $ */
2
3/*
4** Id: luaconf.h
5** Configuration file for Lua
6** See Copyright Notice in lua.h
7*/
8
9
10#ifndef luaconf_h
11#define luaconf_h
12
13#ifndef _KERNEL
14#include <limits.h>
15#include <stddef.h>
16#else /* _KERNEL */
17#include <machine/limits.h>
18#include <sys/systm.h>
19#endif /* _KERNEL */
20
21
22/*
23** ===================================================================
24** General Configuration File for Lua
25**
26** Some definitions here can be changed externally, through the compiler
27** (e.g., with '-D' options): They are commented out or protected
28** by '#if !defined' guards. However, several other definitions
29** should be changed directly here, either because they affect the
30** Lua ABI (by making the changes here, you ensure that all software
31** connected to Lua, such as C libraries, will be compiled with the same
32** configuration); or because they are seldom changed.
33**
34** Search for "@@" to find all configurable definitions.
35** ===================================================================
36*/
37
38
39/*
40** {====================================================================
41** System Configuration: macros to adapt (if needed) Lua to some
42** particular platform, for instance restricting it to C89.
43** =====================================================================
44*/
45
46/*
47@@ LUA_USE_C89 controls the use of non-ISO-C89 features.
48** Define it if you want Lua to avoid the use of a few C99 features
49** or Windows-specific features on Windows.
50*/
51/* #define LUA_USE_C89 */
52
53
54/*
55** By default, Lua on Windows use (some) specific Windows features
56*/
57#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
58#define LUA_USE_WINDOWS /* enable goodies for regular Windows */
59#endif
60
61
62#if defined(LUA_USE_WINDOWS)
63#define LUA_DL_DLL /* enable support for DLL */
64#define LUA_USE_C89 /* broadly, Windows is C89 */
65#endif
66
67
68#if defined(LUA_USE_LINUX)
69#define LUA_USE_POSIX
70#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
71#endif
72
73
74#if defined(LUA_USE_MACOSX)
75#define LUA_USE_POSIX
76#define LUA_USE_DLOPEN /* MacOS does not need -ldl */
77#endif
78
79
80#if defined(LUA_USE_IOS)
81#define LUA_USE_POSIX
82#define LUA_USE_DLOPEN
83#endif
84
85
86/*
87@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
88*/
89#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3)
90
91/* }================================================================== */
92
93
94
95/*
96** {==================================================================
97** Configuration for Number types. These options should not be
98** set externally, because any other code connected to Lua must
99** use the same configuration.
100** ===================================================================
101*/
102
103/*
104@@ LUA_INT_TYPE defines the type for Lua integers.
105@@ LUA_FLOAT_TYPE defines the type for Lua floats.
106** Lua should work fine with any mix of these options supported
107** by your C compiler. The usual configurations are 64-bit integers
108** and 'double' (the default), 32-bit integers and 'float' (for
109** restricted platforms), and 'long'/'double' (for C compilers not
110** compliant with C99, which may not have support for 'long long').
111*/
112
113/* predefined options for LUA_INT_TYPE */
114#define LUA_INT_INT 1
115#define LUA_INT_LONG 2
116#define LUA_INT_LONGLONG 3
117
118/* predefined options for LUA_FLOAT_TYPE */
119#define LUA_FLOAT_FLOAT 1
120#define LUA_FLOAT_DOUBLE 2
121#define LUA_FLOAT_LONGDOUBLE 3
122
123
124/* Default configuration ('long long' and 'double', for 64-bit Lua) */
125#define LUA_INT_DEFAULT LUA_INT_LONGLONG
126#define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE
127
128
129/*
130@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats.
131*/
132#define LUA_32BITS 0
133
134
135/*
136@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
137** C89 ('long' and 'double'); Windows always has '__int64', so it does
138** not need to use this case.
139*/
140#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
141#define LUA_C89_NUMBERS 1
142#else
143#define LUA_C89_NUMBERS 0
144#endif
145
146
147#if LUA_32BITS /* { */
148/*
149** 32-bit integers and 'float'
150*/
151#if LUAI_IS32INT /* use 'int' if big enough */
152#define LUA_INT_TYPE LUA_INT_INT
153#else /* otherwise use 'long' */
154#define LUA_INT_TYPE LUA_INT_LONG
155#endif
156#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT
157
158#elif LUA_C89_NUMBERS /* }{ */
159/*
160** largest types available for C89 ('long' and 'double')
161*/
162#define LUA_INT_TYPE LUA_INT_LONG
163#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
164
165#else /* }{ */
166/* use defaults */
167
168#define LUA_INT_TYPE LUA_INT_DEFAULT
169#define LUA_FLOAT_TYPE LUA_FLOAT_DEFAULT
170
171#endif /* } */
172
173
174/* }================================================================== */
175
176
177
178/*
179** {==================================================================
180** Configuration for Paths.
181** ===================================================================
182*/
183
184/*
185** LUA_PATH_SEP is the character that separates templates in a path.
186** LUA_PATH_MARK is the string that marks the substitution points in a
187** template.
188** LUA_EXEC_DIR in a Windows path is replaced by the executable's
189** directory.
190*/
191#define LUA_PATH_SEP ";"
192#define LUA_PATH_MARK "?"
193#define LUA_EXEC_DIR "!"
194
195
196/*
197@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
198** Lua libraries.
199@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
200** C libraries.
201** CHANGE them if your machine has a non-conventional directory
202** hierarchy or if you want to install your libraries in
203** non-conventional directories.
204*/
205
206#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
207#if defined(_WIN32) /* { */
208/*
209** In Windows, any exclamation mark ('!') in the path is replaced by the
210** path of the directory of the executable file of the current process.
211*/
212#define LUA_LDIR "!\\lua\\"
213#define LUA_CDIR "!\\"
214#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\"
215
216#if !defined(LUA_PATH_DEFAULT)
217#define LUA_PATH_DEFAULT \
218 LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
219 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \
220 LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
221 ".\\?.lua;" ".\\?\\init.lua"
222#endif
223
224#if !defined(LUA_CPATH_DEFAULT)
225#define LUA_CPATH_DEFAULT \
226 LUA_CDIR"?.dll;" \
227 LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
228 LUA_CDIR"loadall.dll;" ".\\?.dll"
229#endif
230
231#else /* }{ */
232
233#define LUA_ROOT "/usr/local/"
234#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
235#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
236
237#if !defined(LUA_PATH_DEFAULT)
238#define LUA_PATH_DEFAULT \
239 LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
240 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
241 "./?.lua;" "./?/init.lua"
242#endif
243
244#if !defined(LUA_CPATH_DEFAULT)
245#define LUA_CPATH_DEFAULT \
246 LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
247#endif
248
249#endif /* } */
250
251
252/*
253@@ LUA_DIRSEP is the directory separator (for submodules).
254** CHANGE it if your machine does not use "/" as the directory separator
255** and is not Windows. (On Windows Lua automatically uses "\".)
256*/
257#if !defined(LUA_DIRSEP)
258
259#if defined(_WIN32)
260#define LUA_DIRSEP "\\"
261#else
262#define LUA_DIRSEP "/"
263#endif
264
265#endif
266
267/* }================================================================== */
268
269
270/*
271** {==================================================================
272** Marks for exported symbols in the C code
273** ===================================================================
274*/
275
276/*
277@@ LUA_API is a mark for all core API functions.
278@@ LUALIB_API is a mark for all auxiliary library functions.
279@@ LUAMOD_API is a mark for all standard library opening functions.
280** CHANGE them if you need to define those functions in some special way.
281** For instance, if you want to create one Windows DLL with the core and
282** the libraries, you may want to use the following definition (define
283** LUA_BUILD_AS_DLL to get it).
284*/
285#if defined(LUA_BUILD_AS_DLL) /* { */
286
287#if defined(LUA_CORE) || defined(LUA_LIB) /* { */
288#define LUA_API __declspec(dllexport)
289#else /* }{ */
290#define LUA_API __declspec(dllimport)
291#endif /* } */
292
293#else /* }{ */
294
295#define LUA_API extern
296
297#endif /* } */
298
299
300/*
301** More often than not the libs go together with the core.
302*/
303#define LUALIB_API LUA_API
304#define LUAMOD_API LUA_API
305
306
307/*
308@@ LUAI_FUNC is a mark for all extern functions that are not to be
309** exported to outside modules.
310@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables,
311** none of which to be exported to outside modules (LUAI_DDEF for
312** definitions and LUAI_DDEC for declarations).
313** CHANGE them if you need to mark them in some special way. Elf/gcc
314** (versions 3.2 and later) mark them as "hidden" to optimize access
315** when Lua is compiled as a shared library. Not all elf targets support
316** this attribute. Unfortunately, gcc does not offer a way to check
317** whether the target offers that support, and those without support
318** give a warning about it. To avoid these warnings, change to the
319** default definition.
320*/
321#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
322 defined(__ELF__) /* { */
323#define LUAI_FUNC __attribute__((visibility("internal"))) extern
324#else /* }{ */
325#define LUAI_FUNC extern
326#endif /* } */
327
328#define LUAI_DDEC(dec) LUAI_FUNC dec
329#define LUAI_DDEF /* empty */
330
331/* }================================================================== */
332
333
334/*
335** {==================================================================
336** Compatibility with previous versions
337** ===================================================================
338*/
339
340/*
341@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3.
342** You can define it to get all options, or change specific options
343** to fit your specific needs.
344*/
345#if defined(LUA_COMPAT_5_3) /* { */
346
347/*
348@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
349** functions in the mathematical library.
350** (These functions were already officially removed in 5.3;
351** nevertheless they are still available here.)
352*/
353#define LUA_COMPAT_MATHLIB
354
355/*
356@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
357** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
358** luaL_checkint, luaL_checklong, etc.)
359** (These macros were also officially removed in 5.3, but they are still
360** available here.)
361*/
362#define LUA_COMPAT_APIINTCASTS
363
364
365/*
366@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod
367** using '__lt'.
368*/
369#define LUA_COMPAT_LT_LE
370
371
372/*
373@@ The following macros supply trivial compatibility for some
374** changes in the API. The macros themselves document how to
375** change your code to avoid using them.
376** (Once more, these macros were officially removed in 5.3, but they are
377** still available here.)
378*/
379#define lua_strlen(L,i) lua_rawlen(L, (i))
380
381#define lua_objlen(L,i) lua_rawlen(L, (i))
382
383#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
384#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
385
386#endif /* } */
387
388/* }================================================================== */
389
390
391
392/*
393** {==================================================================
394** Configuration for Numbers (low-level part).
395** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
396** satisfy your needs.
397** ===================================================================
398*/
399
400#ifndef _KERNEL
401/*
402@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
403@@ over a floating number.
404@@ l_floatatt(x) corrects float attribute 'x' to the proper float type
405** by prefixing it with one of FLT/DBL/LDBL.
406@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
407@@ LUA_NUMBER_FMT is the format for writing floats.
408@@ lua_number2str converts a float to a string.
409@@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
410@@ l_floor takes the floor of a float.
411@@ lua_str2number converts a decimal numeral to a number.
412*/
413
414
415/* The following definitions are good for most cases here */
416
417#define l_floor(x) (l_mathop(floor)(x))
418
419#define lua_number2str(s,sz,n) \
420 l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
421
422/*
423@@ lua_numbertointeger converts a float number with an integral value
424** to an integer, or returns 0 if float is not within the range of
425** a lua_Integer. (The range comparisons are tricky because of
426** rounding. The tests here assume a two-complement representation,
427** where MININTEGER always has an exact representation as a float;
428** MAXINTEGER may not have one, and therefore its conversion to float
429** may have an ill-defined value.)
430*/
431#define lua_numbertointeger(n,p) \
432 ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
433 (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
434 (*(p) = (LUA_INTEGER)(n), 1))
435
436
437/* now the variable definitions */
438
439#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */
440
441#define LUA_NUMBER float
442
443#define l_floatatt(n) (FLT_##n)
444
445#define LUAI_UACNUMBER double
446
447#define LUA_NUMBER_FRMLEN ""
448#define LUA_NUMBER_FMT "%.7g"
449
450#define l_mathop(op) op##f
451
452#define lua_str2number(s,p) strtof((s), (p))
453
454
455#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */
456
457#define LUA_NUMBER long double
458
459#define l_floatatt(n) (LDBL_##n)
460
461#define LUAI_UACNUMBER long double
462
463#define LUA_NUMBER_FRMLEN "L"
464#define LUA_NUMBER_FMT "%.19Lg"
465
466#define l_mathop(op) op##l
467
468#define lua_str2number(s,p) strtold((s), (p))
469
470#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */
471
472#define LUA_NUMBER double
473
474#define l_floatatt(n) (DBL_##n)
475
476#define LUAI_UACNUMBER double
477
478#define LUA_NUMBER_FRMLEN ""
479#define LUA_NUMBER_FMT "%.14g"
480
481#define l_mathop(op) op
482
483#define lua_str2number(s,p) strtod((s), (p))
484
485#else /* }{ */
486
487#error "numeric float type not defined"
488
489#endif /* } */
490#endif /*_KERNEL */
491
492
493
494/*
495@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
496@@ LUAI_UACINT is the result of a 'default argument promotion'
497@@ over a LUA_INTEGER.
498@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
499@@ LUA_INTEGER_FMT is the format for writing integers.
500@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
501@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
502@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
503@@ lua_integer2str converts an integer to a string.
504*/
505
506
507/* The following definitions are good for most cases here */
508
509#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
510
511#define LUAI_UACINT LUA_INTEGER
512
513#define lua_integer2str(s,sz,n) \
514 l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
515
516/*
517** use LUAI_UACINT here to avoid problems with promotions (which
518** can turn a comparison between unsigneds into a signed comparison)
519*/
520#define LUA_UNSIGNED unsigned LUAI_UACINT
521
522
523/* now the variable definitions */
524
525#if LUA_INT_TYPE == LUA_INT_INT /* { int */
526
527#define LUA_INTEGER int
528#define LUA_INTEGER_FRMLEN ""
529
530#define LUA_MAXINTEGER INT_MAX
531#define LUA_MININTEGER INT_MIN
532
533#define LUA_MAXUNSIGNED UINT_MAX
534
535#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */
536
537#define LUA_INTEGER long
538#define LUA_INTEGER_FRMLEN "l"
539
540#define LUA_MAXINTEGER LONG_MAX
541#define LUA_MININTEGER LONG_MIN
542
543#define LUA_MAXUNSIGNED ULONG_MAX
544
545#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */
546
547/* use presence of macro LLONG_MAX as proxy for C99 compliance */
548#if defined(LLONG_MAX) /* { */
549/* use ISO C99 stuff */
550
551#define LUA_INTEGER long long
552#define LUA_INTEGER_FRMLEN "ll"
553
554#define LUA_MAXINTEGER LLONG_MAX
555#define LUA_MININTEGER LLONG_MIN
556
557#define LUA_MAXUNSIGNED ULLONG_MAX
558
559#elif defined(LUA_USE_WINDOWS) /* }{ */
560/* in Windows, can use specific Windows types */
561
562#define LUA_INTEGER __int64
563#define LUA_INTEGER_FRMLEN "I64"
564
565#define LUA_MAXINTEGER _I64_MAX
566#define LUA_MININTEGER _I64_MIN
567
568#define LUA_MAXUNSIGNED _UI64_MAX
569
570#else /* }{ */
571
572#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
573 or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
574
575#endif /* } */
576
577#else /* }{ */
578
579#error "numeric integer type not defined"
580
581#endif /* } */
582
583/* }================================================================== */
584
585
586/*
587** {==================================================================
588** Dependencies with C99 and other C details
589** ===================================================================
590*/
591
592/*
593@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
594** (All uses in Lua have only one format item.)
595*/
596#if !defined(LUA_USE_C89)
597#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i)
598#else
599#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i))
600#endif
601
602
603/*
604@@ lua_strx2number converts a hexadecimal numeral to a number.
605** In C99, 'strtod' does that conversion. Otherwise, you can
606** leave 'lua_strx2number' undefined and Lua will provide its own
607** implementation.
608*/
609#if !defined(LUA_USE_C89)
610#define lua_strx2number(s,p) lua_str2number(s,p)
611#endif
612
613
614/*
615@@ lua_pointer2str converts a pointer to a readable string in a
616** non-specified way.
617*/
618#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p)
619
620
621/*
622@@ lua_number2strx converts a float to a hexadecimal numeral.
623** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
624** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
625** provide its own implementation.
626*/
627#if !defined(LUA_USE_C89)
628#define lua_number2strx(L,b,sz,f,n) \
629 ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
630#endif
631
632
633/*
634** 'strtof' and 'opf' variants for math functions are not valid in
635** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
636** availability of these variants. ('math.h' is already included in
637** all files that use these macros.)
638*/
639#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
640#undef l_mathop /* variants not available */
641#undef lua_str2number
642#define l_mathop(op) (lua_Number)op /* no variant */
643#define lua_str2number(s,p) ((lua_Number)strtod((s), (p)))
644#endif
645
646
647/*
648@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
649** functions. It must be a numerical type; Lua will use 'intptr_t' if
650** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
651** 'intptr_t' in C89)
652*/
653#define LUA_KCONTEXT ptrdiff_t
654
655#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
656 __STDC_VERSION__ >= 199901L
657#include <stdint.h>
658#if defined(INTPTR_MAX) /* even in C99 this type is optional */
659#undef LUA_KCONTEXT
660#define LUA_KCONTEXT intptr_t
661#endif
662#endif
663
664
665/*
666@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
667** Change that if you do not want to use C locales. (Code using this
668** macro must include the header 'locale.h'.)
669*/
670#if !defined(lua_getlocaledecpoint)
671#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
672#endif
673
674
675/*
676** macros to improve jump prediction, used mostly for error handling
677** and debug facilities. (Some macros in the Lua API use these macros.
678** Define LUA_NOBUILTIN if you do not want '__builtin_expect' in your
679** code.)
680*/
681#if !defined(luai_likely)
682
683#if defined(__GNUC__) && !defined(LUA_NOBUILTIN)
684#define luai_likely(x) (__builtin_expect(((x) != 0), 1))
685#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0))
686#else
687#define luai_likely(x) (x)
688#define luai_unlikely(x) (x)
689#endif
690
691#endif
692
693
694#if defined(LUA_CORE) || defined(LUA_LIB)
695/* shorter names for Lua's own use */
696#define l_likely(x) luai_likely(x)
697#define l_unlikely(x) luai_unlikely(x)
698#endif
699
700
701
702/* }================================================================== */
703
704
705/*
706** {==================================================================
707** Language Variations
708** =====================================================================
709*/
710
711/*
712@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
713** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
714** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
715** coercion from strings to numbers.
716*/
717/* #define LUA_NOCVTN2S */
718/* #define LUA_NOCVTS2N */
719
720
721/*
722@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
723** Define it as a help when debugging C code.
724*/
725#if defined(LUA_USE_APICHECK)
726#include <assert.h>
727#define luai_apicheck(l,e) assert(e)
728#endif
729
730/* }================================================================== */
731
732
733/*
734** {==================================================================
735** Macros that affect the API and must be stable (that is, must be the
736** same when you compile Lua and when you compile code that links to
737** Lua).
738** =====================================================================
739*/
740
741/*
742@@ LUAI_MAXSTACK limits the size of the Lua stack.
743** CHANGE it if you need a different limit. This limit is arbitrary;
744** its only purpose is to stop Lua from consuming unlimited stack
745** space (and to reserve some numbers for pseudo-indices).
746** (It must fit into max(size_t)/32 and max(int)/2.)
747*/
748#if LUAI_IS32INT
749#define LUAI_MAXSTACK 1000000
750#else
751#define LUAI_MAXSTACK 15000
752#endif
753
754
755/*
756@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
757** a Lua state with very fast access.
758** CHANGE it if you need a different size.
759*/
760#define LUA_EXTRASPACE (sizeof(void *))
761
762
763/*
764@@ LUA_IDSIZE gives the maximum size for the description of the source
765** of a function in debug information.
766** CHANGE it if you want a different size.
767*/
768#define LUA_IDSIZE 60
769
770
771/*
772@@ LUAL_BUFFERSIZE is the initial buffer size used by the lauxlib
773** buffer system.
774*/
775#ifdef _KERNEL
776#define LUAL_BUFFERSIZE 128
777#else
778#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number)))
779#endif
780
781/* }================================================================== */
782
783
784/*
785@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
786** maximum alignment for the other items in that union.
787*/
788#ifndef _KERNEL
789#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
790#else /* _KERNEL */
791#define LUAI_MAXALIGN lua_Number n; void *s; lua_Integer i; long l
792#endif
793
794/* }================================================================== */
795
796
797
798
799
800/* =================================================================== */
801
802/*
803** Local configuration. You can use this space to add your redefinitions
804** without modifying the main part of the file.
805*/
806
807#ifdef __NetBSD__
808
809#define LUA_STRFTIMEOPTIONS "aAbBcCdDeFgGhHIjklmMnprRsStTuUvVwWxXyYzZ%"
810
811/* Integer types */
812#undef LUA_INTEGER
813#undef LUA_INTEGER_FRMLEN
814#undef LUA_UNSIGNED
815#undef LUA_MAXUNSIGNED
816#undef LUA_MAXINTEGER
817#undef LUA_MININTEGER
818
819#define LUA_INTEGER intmax_t
820#define LUA_INTEGER_FRMLEN "j"
821#define LUA_UNSIGNED uintmax_t
822#define LUA_MAXUNSIGNED UINTMAX_MAX
823#define LUA_MAXINTEGER INTMAX_MAX
824#define LUA_MININTEGER INTMAX_MIN
825
826/* Path */
827#undef LUA_ROOT
828#undef LUA_PATH_DEFAULT
829#undef LUA_CPATH_DEFAULT
830
831#define LUA_ROOT "/usr/"
832#define LUA_PATH_DEFAULT \
833 LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
834 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
835#define LUA_CPATH_DEFAULT \
836 LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
837
838#ifndef _KERNEL
839
840#include <stdint.h>
841
842#else /* _KERNEL */
843
844#define LUA_NUMBER LUA_INTEGER
845#define LUA_NUMBER_FMT LUA_INTEGER_FMT
846
847#define l_mathlim(n) (0)
848#define l_randomizePivot() (~0)
849
850/* setjmp.h */
851#define LUAI_THROW(L,c) longjmp(&((c)->b))
852#define LUAI_TRY(L,c,a) if (setjmp(&((c)->b)) == 0) { a }
853#define luai_jmpbuf label_t
854
855/* time.h */
856#include <sys/time.h>
857#define time(p) (time_uptime)
858
859/* stdio.h */
860#define lua_writestring(s,l) printf("%s", (s))
861#define lua_writeline() printf("\n")
862
863/* string.h */
864#define strcoll strcmp
865
866/* stdlib.h */
867#define abort() panic("Lua has aborted!")
868
869#endif /* _KERNEL */
870
871#endif /* __NetBSD__ */
872
873#endif
\ No newline at end of file
lib/libc/include/generic-netbsd/lualib.h created+54
......@@ -0,0 +1,54 @@
1/* $NetBSD: lualib.h,v 1.7.10.1 2023/08/11 16:22:07 martin Exp $ */
2
3/*
4** Id: lualib.h
5** Lua standard libraries
6** See Copyright Notice in lua.h
7*/
8
9
10#ifndef lualib_h
11#define lualib_h
12
13#include "lua.h"
14
15
16/* version suffix for environment variable names */
17#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
18
19
20LUAMOD_API int (luaopen_base) (lua_State *L);
21
22#define LUA_COLIBNAME "coroutine"
23LUAMOD_API int (luaopen_coroutine) (lua_State *L);
24
25#define LUA_TABLIBNAME "table"
26LUAMOD_API int (luaopen_table) (lua_State *L);
27
28#define LUA_IOLIBNAME "io"
29LUAMOD_API int (luaopen_io) (lua_State *L);
30
31#define LUA_OSLIBNAME "os"
32LUAMOD_API int (luaopen_os) (lua_State *L);
33
34#define LUA_STRLIBNAME "string"
35LUAMOD_API int (luaopen_string) (lua_State *L);
36
37#define LUA_UTF8LIBNAME "utf8"
38LUAMOD_API int (luaopen_utf8) (lua_State *L);
39
40#define LUA_MATHLIBNAME "math"
41LUAMOD_API int (luaopen_math) (lua_State *L);
42
43#define LUA_DBLIBNAME "debug"
44LUAMOD_API int (luaopen_debug) (lua_State *L);
45
46#define LUA_LOADLIBNAME "package"
47LUAMOD_API int (luaopen_package) (lua_State *L);
48
49
50/* open all previous libraries */
51LUALIB_API void (luaL_openlibs) (lua_State *L);
52
53
54#endif
\ No newline at end of file
lib/libc/include/generic-netbsd/machine/bswap.h+7-2
......@@ -1,3 +1,8 @@
1/* $NetBSD: bswap.h,v 1.1 2002/12/09 12:15:58 scw Exp $ */
1/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:55 simonb Exp $ */
22
3#include <powerpc/bswap.h>
\ No newline at end of file
3#ifndef _MACHINE_BSWAP_H_
4#define _MACHINE_BSWAP_H_
5
6#include <sys/bswap.h>
7
8#endif /* !_MACHINE_BSWAP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/machine/byte_swap.h+64-42
......@@ -1,11 +1,11 @@
1/* $NetBSD: byte_swap.h,v 1.5 2020/04/04 21:13:20 christos Exp $ */
1/* $NetBSD: byte_swap.h,v 1.16 2017/01/17 11:08:50 rin Exp $ */
22
33/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
4 * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc.
55 * All rights reserved.
66 *
77 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
8 * by Charles M. Hannum, Neil A. Carson, and Jason R. Thorpe.
99 *
1010 * Redistribution and use in source and binary forms, with or without
1111 * modification, are permitted provided that the following conditions
......@@ -29,57 +29,57 @@
2929 * POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
32#ifndef _RISCV_BYTE_SWAP_H_
33#define _RISCV_BYTE_SWAP_H_
32#ifndef _ARM_BYTE_SWAP_H_
33#define _ARM_BYTE_SWAP_H_
3434
3535#ifdef _LOCORE
3636
37#define BSWAP16(_src, _dst, _tmp) \
38 andi _dst, _src, 0xff ;\
39 slli _dst, _dst, 8 ;\
40 srli _tmp, _src, 8 ;\
41 and _tmp, _tmp, 0xff ;\
42 ori _dst, _dst, _tmp
43
44#define BSWAP32(_src, _dst, _tmp) \
45 li v1, 0xff00 ;\
46 slli _dst, _src, 24 ;\
47 srli _tmp, _src, 24 ;\
48 ori _dst, _dst, _tmp ;\
49 and _tmp, _src, v1 ;\
50 slli _tmp, _src, 8 ;\
51 ori _dst, _dst, _tmp ;\
52 srli _tmp, _src, 8 ;\
53 and _tmp, _tmp, v1 ;\
54 ori _dst, _dst, _tmp
37#if defined(_ARM_ARCH_6) || defined(_ARM_ARCH_7)
38
39#define BSWAP16(_src, _dst, _tmp) \
40 rev16 _dst, _src
41#define BSWAP32(_src, _dst, _tmp) \
42 rev _dst, _src
5543
5644#else
5745
58#include <sys/types.h>
59__BEGIN_DECLS
46#define BSWAP16(_src, _dst, _tmp) \
47 mov _tmp, _src, ror #8 ;\
48 orr _tmp, _tmp, _tmp, lsr #16 ;\
49 bic _dst, _tmp, _tmp, lsl #16
6050
61#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable
62static __inline uint64_t
63__byte_swap_u64_variable(uint64_t v)
64{
65 const uint64_t m1 = 0x0000ffff0000ffffull;
66 const uint64_t m0 = 0x00ff00ff00ff00ffull;
51#define BSWAP32(_src, _dst, _tmp) \
52 eor _tmp, _src, _src, ror #16 ;\
53 bic _tmp, _tmp, #0x00FF0000 ;\
54 mov _dst, _src, ror #8 ;\
55 eor _dst, _dst, _tmp, lsr #8
6756
68 v = (v >> 32) | (v << 32);
69 v = ((v >> 16) & m1) | ((v & m1) << 16);
70 v = ((v >> 8) & m0) | ((v & m0) << 8);
57#endif
7158
72 return v;
73}
59
60#else
61
62#ifdef __GNUC__
63#include <sys/types.h>
64__BEGIN_DECLS
7465
7566#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
7667static __inline uint32_t
7768__byte_swap_u32_variable(uint32_t v)
7869{
79 const uint32_t m = 0xff00ff;
70 uint32_t t1;
71
72#ifdef _ARM_ARCH_6
73 if (!__builtin_constant_p(v)) {
74 __asm("rev\t%0, %1" : "=r" (v) : "0" (v));
75 return v;
76 }
77#endif
8078
81 v = (v >> 16) | (v << 16);
82 v = ((v >> 8) & m) | ((v & m) << 8);
79 t1 = v ^ ((v << 16) | (v >> 16));
80 t1 &= 0xff00ffffU;
81 v = (v >> 8) | (v << 24);
82 v ^= (t1 >> 8);
8383
8484 return v;
8585}
......@@ -88,12 +88,34 @@ __byte_swap_u32_variable(uint32_t v)
8888static __inline uint16_t
8989__byte_swap_u16_variable(uint16_t v)
9090{
91 /*LINTED*/
92 return (uint16_t)((v >> 8) | (v << 8));
91
92#ifdef _ARM_ARCH_6
93 if (!__builtin_constant_p(v)) {
94 uint32_t v32 = v;
95 __asm("rev16\t%0, %1" : "=r" (v32) : "0" (v32));
96 return (uint16_t)v32;
97 }
98#elif !defined(__thumb__) && 0 /* gcc produces decent code for this */
99 if (!__builtin_constant_p(v)) {
100 uint32_t v0 = v;
101 __asm volatile(
102 "mov %0, %1, ror #8\n"
103 "orr %0, %0, %0, lsr #16\n"
104 "bic %0, %0, %0, lsl #16"
105 : "=&r" (v0)
106 : "0" (v0));
107 return (uint16_t)v0;
108 }
109#endif
110 v &= 0xffff;
111 v = (uint16_t)((v >> 8) | (v << 8));
112
113 return v;
93114}
94115
95116__END_DECLS
117#endif
96118
97119#endif /* _LOCORE */
98120
99#endif /* _RISCV_BYTE_SWAP_H_ */
\ No newline at end of file
121#endif /* _ARM_BYTE_SWAP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/machine/endian_machdep.h+2-2
......@@ -1,3 +1,3 @@
1/* $NetBSD: endian_machdep.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */
1/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:25 mycroft Exp $ */
22
3#include <powerpc/endian_machdep.h>
\ No newline at end of file
3#define _BYTE_ORDER _BIG_ENDIAN
\ No newline at end of file
lib/libc/include/generic-netbsd/machine/rwlock.h+1-3
......@@ -1,3 +1 @@
1/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */
2
3#include <powerpc/rwlock.h>
\ No newline at end of file
1/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:53 riastradh Exp $ */
\ No newline at end of file
lib/libc/include/generic-netbsd/machine/sysarch.h+84-2
......@@ -1,3 +1,85 @@
1/* $NetBSD: sysarch.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
1/* $NetBSD: sysarch.h,v 1.15 2021/10/06 05:33:15 skrll Exp $ */
22
3/* nothing */
\ No newline at end of file
3/*
4 * Copyright (c) 1996-1997 Mark Brinicombe.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Mark Brinicombe.
18 * 4. The name of the company nor the name of the author may be used to
19 * endorse or promote products derived from this software without specific
20 * prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#ifndef _ARM_SYSARCH_H_
36#define _ARM_SYSARCH_H_
37
38#include <sys/cdefs.h>
39
40/*
41 * Pickup definition of size_t and uintptr_t
42 */
43#include <machine/ansi.h>
44#include <sys/stdint.h>
45#ifndef _KERNEL
46#include <stdbool.h>
47#endif
48
49#ifdef _BSD_SIZE_T_
50typedef _BSD_SIZE_T_ size_t;
51#undef _BSD_SIZE_T_
52#endif
53
54/*
55 * Architecture specific syscalls (arm)
56 */
57
58#define ARM_SYNC_ICACHE 0
59#define ARM_DRAIN_WRITEBUF 1
60#define ARM_VFP_FPSCR 2
61#define ARM_FPU_USED 3
62
63struct arm_sync_icache_args {
64 uintptr_t addr; /* Virtual start address */
65 size_t len; /* Region size */
66};
67
68struct arm_vfp_fpscr_args {
69 uint32_t fpscr_clear; /* bits to clear */
70 uint32_t fpscr_set; /* bits to set */
71};
72
73struct arm_unaligned_faults_args {
74 bool enabled; /* unaligned faults are enabled */
75};
76
77#ifndef _KERNEL
78__BEGIN_DECLS
79int arm_sync_icache(uintptr_t, size_t);
80int arm_drain_writebuf(void);
81int sysarch(int, void *);
82__END_DECLS
83#endif
84
85#endif /* !_ARM_SYSARCH_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/machine/sysreg.h deleted-337
......@@ -1,337 +0,0 @@
1/* $NetBSD: sysreg.h,v 1.28 2022/12/03 11:09:59 skrll Exp $ */
2
3/*
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_SYSREG_H_
33#define _RISCV_SYSREG_H_
34
35#ifndef _KERNEL
36#include <sys/param.h>
37#endif
38
39#include <riscv/reg.h>
40
41#define FCSR_FMASK 0 // no exception bits
42#define FCSR_FRM __BITS(7, 5)
43#define FCSR_FRM_RNE 0b000 // Round Nearest, ties to Even
44#define FCSR_FRM_RTZ 0b001 // Round Towards Zero
45#define FCSR_FRM_RDN 0b010 // Round DowN (-infinity)
46#define FCSR_FRM_RUP 0b011 // Round UP (+infinity)
47#define FCSR_FRM_RMM 0b100 // Round to nearest, ties to Max Magnitude
48#define FCSR_FRM_DYN 0b111 // Dynamic rounding
49#define FCSR_FFLAGS __BITS(4, 0) // Sticky bits
50#define FCSR_NV __BIT(4) // iNValid operation
51#define FCSR_DZ __BIT(3) // Divide by Zero
52#define FCSR_OF __BIT(2) // OverFlow
53#define FCSR_UF __BIT(1) // UnderFlow
54#define FCSR_NX __BIT(0) // iNeXact
55
56static inline uint32_t
57riscvreg_fcsr_read(void)
58{
59 uint32_t __fcsr;
60 __asm("frcsr %0" : "=r"(__fcsr));
61 return __fcsr;
62}
63
64
65static inline uint32_t
66riscvreg_fcsr_write(uint32_t __new)
67{
68 uint32_t __old;
69 __asm("fscsr %0, %1" : "=r"(__old) : "r"(__new));
70 return __old;
71}
72
73static inline uint32_t
74riscvreg_fcsr_read_fflags(void)
75{
76 uint32_t __old;
77 __asm("frflags %0" : "=r"(__old));
78 return __SHIFTOUT(__old, FCSR_FFLAGS);
79}
80
81static inline uint32_t
82riscvreg_fcsr_write_fflags(uint32_t __new)
83{
84 uint32_t __old;
85 __new = __SHIFTIN(__new, FCSR_FFLAGS);
86 __asm("fsflags %0, %1" : "=r"(__old) : "r"(__new));
87 return __SHIFTOUT(__old, FCSR_FFLAGS);
88}
89
90static inline uint32_t
91riscvreg_fcsr_read_frm(void)
92{
93 uint32_t __old;
94 __asm("frrm\t%0" : "=r"(__old));
95 return __SHIFTOUT(__old, FCSR_FRM);
96}
97
98static inline uint32_t
99riscvreg_fcsr_write_frm(uint32_t __new)
100{
101 uint32_t __old;
102 __new = __SHIFTIN(__new, FCSR_FRM);
103 __asm __volatile("fsrm\t%0, %1" : "=r"(__old) : "r"(__new));
104 return __SHIFTOUT(__old, FCSR_FRM);
105}
106
107
108#define RISCVREG_READ_INLINE(regname) \
109static inline uintptr_t \
110csr_##regname##_read(void) \
111{ \
112 uintptr_t __rv; \
113 asm volatile("csrr %0, " #regname : "=r"(__rv) :: "memory"); \
114 return __rv; \
115}
116
117#define RISCVREG_WRITE_INLINE(regname) \
118static inline void \
119csr_##regname##_write(uintptr_t __val) \
120{ \
121 asm volatile("csrw " #regname ", %0" :: "r"(__val) : "memory"); \
122}
123
124#define RISCVREG_SET_INLINE(regname) \
125static inline void \
126csr_##regname##_set(uintptr_t __mask) \
127{ \
128 if (__builtin_constant_p(__mask) && __mask < 0x20) { \
129 asm volatile("csrsi " #regname ", %0" :: "i"(__mask) : \
130 "memory"); \
131 } else { \
132 asm volatile("csrs " #regname ", %0" :: "r"(__mask) : \
133 "memory"); \
134 } \
135}
136
137#define RISCVREG_CLEAR_INLINE(regname) \
138static inline void \
139csr_##regname##_clear(uintptr_t __mask) \
140{ \
141 if (__builtin_constant_p(__mask) && __mask < 0x20) { \
142 asm volatile("csrci " #regname ", %0" :: "i"(__mask) : \
143 "memory"); \
144 } else { \
145 asm volatile("csrc " #regname ", %0" :: "r"(__mask) : \
146 "memory"); \
147 } \
148}
149
150#define RISCVREG_READ_WRITE_INLINE(regname) \
151RISCVREG_READ_INLINE(regname) \
152RISCVREG_WRITE_INLINE(regname)
153#define RISCVREG_SET_CLEAR_INLINE(regname) \
154RISCVREG_SET_INLINE(regname) \
155RISCVREG_CLEAR_INLINE(regname)
156#define RISCVREG_READ_SET_CLEAR_INLINE(regname) \
157RISCVREG_READ_INLINE(regname) \
158RISCVREG_SET_CLEAR_INLINE(regname)
159#define RISCVREG_READ_WRITE_SET_CLEAR_INLINE(regname) \
160RISCVREG_READ_WRITE_INLINE(regname) \
161RISCVREG_SET_CLEAR_INLINE(regname)
162
163/* Supervisor Status Register */
164RISCVREG_READ_SET_CLEAR_INLINE(sstatus) // supervisor status register
165#ifdef _LP64
166#define SR_WPRI __BITS(62, 34) | __BITS(31, 20) | \
167 __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \
168 __BIT(0)
169#define SR_SD __BIT(63) // any of FS or VS or XS dirty
170 /* Bits 62-34 are WPRI */
171#define SR_UXL __BITS(33, 32) // U-mode XLEN
172#define SR_UXL_32 1 // XLEN == 32
173#define SR_UXL_64 2 // XLEN == 64
174#define SR_UXL_128 3 // XLEN == 128
175 /* Bits 31-20 are WPRI*/
176#else
177#define SR_WPRI __BITS(30, 20) | \
178 __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \
179 __BIT(0)
180#define SR_SD __BIT(31) // any of FS or VS or XS dirty
181 /* Bits 30-20 are WPRI*/
182#endif /* _LP64 */
183
184/* Both RV32 and RV64 have the bottom 20 bits shared */
185#define SR_MXR __BIT(19) // Make eXecutable Readable
186#define SR_SUM __BIT(18) // permit Supervisor User Memory access
187 /* Bit 17 is WPRI */
188#define SR_XS __BITS(16, 15) // Vector extension state
189#define SR_XS_OFF 0 // All off
190#define SR_XS_SOME_ON 1 // None dirty or clean, some on
191#define SR_XS_SOME_CLEAN 2 // None dirty, some clean
192#define SR_XS_SOME_DIRTY 3 // Some dirty
193#define SR_FS __BITS(14, 13) // Floating-point unit state
194#define SR_FS_OFF 0 // Off
195#define SR_FS_INITIAL 1 // Initial
196#define SR_FS_CLEAN 2 // Clean
197#define SR_FS_DIRTY 3 // Dirty
198 /* Bits 12-11 are WPRI */
199#define SR_VS __BITS(10, 9) // User-mode extention state
200#define SR_VS_OFF SR_FS_OFF // Off
201#define SR_VS_INITIAL SR_FS_INITIAL // Initial
202#define SR_VS_CLEAN SR_FS_CLEAN // Clean
203#define SR_VS_DIRTY SR_FS_DIRTY // Dirty
204#define SR_SPP __BIT(8) // Priv level before supervisor mode
205 /* Bit 7 is WPRI */
206#define SR_UBE __BIT(6) // User-mode endianness
207#define SR_SPIE __BIT(5) // S-Mode interrupts enabled before trap
208 /* Bits 4-2 are WPRI */
209#define SR_SIE __BIT(1) // Supervisor mode interrupt enable
210 /* Bit 0 is WPRI */
211
212/* Supervisor interrupt registers */
213/* ... interrupt pending register (sip) */
214RISCVREG_READ_SET_CLEAR_INLINE(sip) // supervisor interrupt pending
215 /* Bit (XLEN-1) - 10 is WIRI */
216#define SIP_SEIP __BIT(9) // S-mode interrupt pending
217 /* Bit 8-6 is WIRI */
218#define SIP_STIP __BIT(5) // S-mode timer interrupt pending
219 /* Bit 4-2 is WIRI */
220#define SIP_SSIP __BIT(1) // S-mode software interrupt pending
221 /* Bit 0 is WIRI */
222
223/* ... interrupt-enable register (sie) */
224RISCVREG_READ_SET_CLEAR_INLINE(sie) // supervisor interrupt enable
225 /* Bit (XLEN-1) - 10 is WIRI */
226#define SIE_SEIE __BIT(9) // S-mode interrupt enable
227 /* Bit 8-6 is WIRI */
228#define SIE_STIE __BIT(5) // S-mode timer interrupt enable
229 /* Bit 4-2 is WIRI */
230#define SIE_SSIE __BIT(1) // S-mode software interrupt enable
231 /* Bit 0 is WIRI */
232
233/* Mask for all interrupts */
234#define SIE_IM (SIE_SEI |SIE_STIE | SIE_SSIE)
235
236#ifdef _LP64
237#define SR_USER64 (SR_SPIE | SR_UXL_64) // 64-bit U-mode sstatus
238#define SR_USER32 (SR_SPIE | SR_UXL_32) // 32-bit U-mode sstatus
239#else
240#define SR_USER (SR_SPIE) // U-mode sstatus
241#endif
242
243// Cause register
244#define CAUSE_INTERRUPT_P(cause) ((cause) & __BIT(XLEN - 1))
245#define CAUSE_CODE(cause) ((cause) & __BITS(XLEN - 2, 0))
246
247// Cause register - exceptions
248#define CAUSE_FETCH_MISALIGNED 0
249#define CAUSE_FETCH_ACCESS 1
250#define CAUSE_ILLEGAL_INSTRUCTION 2
251#define CAUSE_BREAKPOINT 3
252#define CAUSE_LOAD_MISALIGNED 4
253#define CAUSE_LOAD_ACCESS 5
254#define CAUSE_STORE_MISALIGNED 6
255#define CAUSE_STORE_ACCESS 7
256#define CAUSE_USER_ECALL 8
257#define CAUSE_SYSCALL CAUSE_USER_ECALL /* convenience alias */
258#define CAUSE_SUPERVISOR_ECALL 9
259/* 10 is reserved */
260#define CAUSE_MACHINE_ECALL 11
261#define CAUSE_FETCH_PAGE_FAULT 12
262#define CAUSE_LOAD_PAGE_FAULT 13
263/* 14 is Reserved */
264#define CAUSE_STORE_PAGE_FAULT 15
265/* >= 16 is reserved/custom */
266
267// Cause register - interrupts
268#define IRQ_SUPERVISOR_SOFTWARE 1
269#define IRQ_MACHINE_SOFTWARE 3
270#define IRQ_SUPERVISOR_TIMER 5
271#define IRQ_MACHINE_TIMER 7
272#define IRQ_SUPERVISOR_EXTERNAL 9
273#define IRQ_MACHINE_EXTERNAL 11
274
275RISCVREG_READ_INLINE(time)
276#ifdef _LP64
277RISCVREG_READ_INLINE(cycle)
278#else /* !_LP64 */
279static inline uint64_t
280csr_cycle_read(void)
281{
282 uint32_t __hi0, __hi1, __lo0;
283 do {
284 __asm __volatile(
285 "csrr\t%[__hi0], cycleh"
286 "\n\t" "csrr\t%[__lo0], cycle"
287 "\n\t" "csrr\t%[__hi1], cycleh"
288 : [__hi0] "=r"(__hi0),
289 [__lo0] "=r"(__lo0),
290 [__hi1] "=r"(__hi1));
291 } while (__hi0 != __hi1);
292 return
293 __SHIFTIN(__hi0, __BITS(63, 32)) |
294 __SHIFTIN(__lo0, __BITS(31, 0));
295}
296#endif /* !_LP64 */
297
298#ifdef _LP64
299#define SATP_MODE __BITS(63, 60) // Translation mode
300#define SATP_MODE_BARE 0 // No translation or protection
301 /* modes 1-7 reserved for standard use */
302#define SATP_MODE_SV39 8 // Page-based 39-bit virt addr
303#define SATP_MODE_SV48 9 // Page-based 48-bit virt addr
304#define SATP_MODE_SV57 10 // Page-based 57-bit virt addr
305#define SATP_MODE_SV64 11 // Page-based 64-bit virt addr
306 /* modes 12-13 reserved for standard use */
307 /* modes 14-15 designated for custom use */
308#define SATP_ASID __BITS(59, 44) // Address Space Identifier
309#define SATP_PPN __BITS(43, 0) // Physical Page Number
310#else
311#define SATP_MODE __BIT(31) // Translation mode
312#define SATP_MODE_BARE 0 // No translation or protection
313#define SATP_MODE_SV32 1 // Page-based 32-bit virt addr
314#define SATP_ASID __BITS(30, 22) // Address Space Identifier
315#define SATP_PPN __BITS(21, 0) // Physical Page Number
316#endif
317
318RISCVREG_READ_WRITE_INLINE(satp)
319
320/* Fake "ASID" CSR (a field of SATP register) functions */
321static inline uint32_t
322csr_asid_read(void)
323{
324 uintptr_t satp = csr_satp_read();
325 return __SHIFTOUT(satp, SATP_ASID);
326}
327
328static inline void
329csr_asid_write(uint32_t asid)
330{
331 uintptr_t satp = csr_satp_read();
332 satp &= ~SATP_ASID;
333 satp |= __SHIFTIN(asid, SATP_ASID);
334 csr_satp_write(satp);
335}
336
337#endif /* _RISCV_SYSREG_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/ansi.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: ansi.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#include <sys/common_ansi.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/aout_machdep.h deleted-40
......@@ -1,40 +0,0 @@
1/* $NetBSD: aout_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_AOUT_MACHDEP_H_
33#define _RISCV_AOUT_MACHDEP_H_
34
35#define cpu_exec_aout_makecmds(p, epp) ENOEXEC
36
37/* Size of a page in an object file. */
38#define AOUT_LDPGSZ 4096
39
40#endif /* !_RISCV_AOUT_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/asm.h deleted-266
......@@ -1,266 +0,0 @@
1/* $NetBSD: asm.h,v 1.6 2021/05/01 07:05:07 skrll Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_ASM_H
33#define _RISCV_ASM_H
34
35#define _C_LABEL(x) x
36
37#define __CONCAT(x,y) x ## y
38#define __STRING(x) #x
39
40#define ___CONCAT(x,y) __CONCAT(x,y)
41
42/*
43 * Define -pg profile entry code.
44 * Must always be noreorder, must never use a macro instruction
45 * Final addiu to t9 must always equal the size of this _KERN_MCOUNT
46 */
47#define _KERN_MCOUNT \
48 .set push; \
49 subi sp, sp, CALLFRAME_SIZE; \
50 REG_S a0, CALLFRAME_S0(sp); \
51 REG_S ra, CALLFRAME_RA(sp); \
52 move a0, ra; \
53 call _mcount \
54 REG_L ra, CALLFRAME_RA(sp); \
55 REG_L a0, CALLFRAME_S0(sp); \
56 addi sp, sp, CALLFRAME_SIZ; \
57 .set pop;
58
59#ifdef GPROF
60#define _PROF_PROLOGUE _KERN_MCOUNT
61#else
62#define _PROF_PROLOGUE
63#endif
64
65#ifdef __PIC__
66#define PLT(x) x##@plt
67#else
68#define PLT(x) x
69#endif
70
71/*
72 * WEAK_ALIAS: create a weak alias.
73 */
74#define WEAK_ALIAS(alias,sym) \
75 .weak alias; \
76 alias = sym
77/*
78 * STRONG_ALIAS: create a strong alias.
79 */
80#define STRONG_ALIAS(alias,sym) \
81 .globl alias; \
82 alias = sym
83
84/*
85 * WARN_REFERENCES: create a warning if the specified symbol is referenced.
86 */
87#define WARN_REFERENCES(sym,msg) \
88 .pushsection __CONCAT(.gnu.warning.,sym); \
89 .ascii msg; \
90 .popsection
91
92#define _ENTRY(x) \
93 .globl _C_LABEL(x); \
94 .type _C_LABEL(x), @function; \
95 _C_LABEL(x):
96
97#define ENTRY_NP(x) .text; .align 2; _ENTRY(x)
98#define ENTRY(x) ENTRY_NP(x); _PROF_PROLOGUE
99#define END(x) .size _C_LABEL(x), . - _C_LABEL(x)
100
101/*
102 * Macros to panic and printf from assembly language.
103 */
104#define PANIC(msg) \
105 la a0, 9f; \
106 call _C_LABEL(panic); \
107 MSG(msg)
108
109#define PRINTF(msg) \
110 la a0, 9f; \
111 call _C_LABEL(printf); \
112 MSG(msg)
113
114#define MSG(msg) \
115 .pushsection .rodata.str1.8,"aMS",@progbits,1; \
1169: .asciiz msg; \
117 .popsection
118
119#define ASMSTR(str) \
120 .asciiz str; \
121 .align 3
122
123#define __RCSID(x) .pushsection ".ident","MS",@progbits,1; \
124 .asciz x; \
125 .popsection
126#define RCSID(name) __RCSID(name)
127
128#if defined(_LP64)
129#define SZREG 8
130#else
131#define SZREG 4
132#endif
133
134#define ALSK 15 /* stack alignment */
135#define ALMASK -15 /* stack alignment */
136#define SZFPREG 8
137#define FP_L fld
138#define FP_S fsd
139
140/*
141 * standard callframe {
142 * register_t cf_sp; frame pointer
143 * register_t cf_ra; return address
144 * };
145 */
146#define CALLFRAME_SIZ (SZREG * 4)
147#define CALLFRAME_S1 (CALLFRAME_SIZ - 4 * SZREG)
148#define CALLFRAME_S0 (CALLFRAME_SIZ - 3 * SZREG)
149#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG)
150#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG)
151
152/*
153 * These macros hide the use of rv32 and rv64 instructions from the
154 * assembler to prevent the assembler from generating 64-bit style
155 * ABI calls.
156 */
157#define PTR_ADD add
158#define PTR_ADDI addi
159#define PTR_SUB sub
160#define PTR_SUBI subi
161#define PTR_LA la
162#define PTR_SLLI slli
163#define PTR_SLL sll
164#define PTR_SRLI srli
165#define PTR_SRL srl
166#define PTR_SRAI srai
167#define PTR_SRA sra
168#if _LP64
169#define PTR_L ld
170#define PTR_S sd
171#define PTR_LR lr.d
172#define PTR_SC sc.d
173#define PTR_WORD .dword
174#define PTR_SCALESHIFT 3
175#else
176#define PTR_L lw
177#define PTR_S sw
178#define PTR_LR lr.w
179#define PTR_SC sc.w
180#define PTR_WORD .word
181#define PTR_SCALESHIFT 2
182#endif
183
184#define INT_L lw
185#define INT_LA la
186#define INT_S sw
187#define INT_LR lr.w
188#define INT_SC sc.w
189#define INT_WORD .word
190#define INT_SCALESHIFT 2
191#ifdef _LP64
192#define INT_ADD addw
193#define INT_ADDI addwi
194#define INT_SUB subw
195#define INT_SUBI subwi
196#define INT_SLL sllwi
197#define INT_SLLV sllw
198#define INT_SRL srlwi
199#define INT_SRLV srlw
200#define INT_SRA srawi
201#define INT_SRAV sraw
202#else
203#define INT_ADD add
204#define INT_ADDI addi
205#define INT_SUB sub
206#define INT_SUBI subi
207#define INT_SLLI slli
208#define INT_SLL sll
209#define INT_SRLI srli
210#define INT_SRL srl
211#define INT_SRAI srai
212#define INT_SRA sra
213#endif
214
215#define LONG_LA la
216#define LONG_ADD add
217#define LONG_ADDI addi
218#define LONG_SUB sub
219#define LONG_SUBI subi
220#define LONG_SLLI slli
221#define LONG_SLL sll
222#define LONG_SRLI srli
223#define LONG_SRL srl
224#define LONG_SRAI srai
225#define LONG_SRA sra
226#ifdef _LP64
227#define LONG_L ld
228#define LONG_S sd
229#define LONG_LR lr.d
230#define LONG_SC sc.d
231#define LONG_WORD .quad
232#define LONG_SCALESHIFT 3
233#else
234#define LONG_L lw
235#define LONG_S sw
236#define LONG_LR lr.w
237#define LONG_SC sc.w
238#define LONG_WORD .word
239#define LONG_SCALESHIFT 2
240#endif
241
242#define REG_LI li
243#define REG_ADD add
244#define REG_SLLI slli
245#define REG_SLL sll
246#define REG_SRLI srli
247#define REG_SRL srl
248#define REG_SRAI srai
249#define REG_SRA sra
250#if _LP64
251#define REG_L ld
252#define REG_S sd
253#define REG_LR lr.d
254#define REG_SC sc.d
255#define REG_SCALESHIFT 3
256#else
257#define REG_L lw
258#define REG_S sw
259#define REG_LR lr.w
260#define REG_SC sc.w
261#define REG_SCALESHIFT 2
262#endif
263
264#define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off)
265
266#endif /* _RISCV_ASM_H */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/bswap.h deleted-11
......@@ -1,11 +0,0 @@
1/* $NetBSD: bswap.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#ifndef _RISCV_BSWAP_H_
4#define _RISCV_BSWAP_H_
5
6#include <riscv/byte_swap.h>
7
8#define __BSWAP_RENAME
9#include <sys/bswap.h>
10
11#endif /* _RISCV_BSWAP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/byte_swap.h deleted-99
......@@ -1,99 +0,0 @@
1/* $NetBSD: byte_swap.h,v 1.5 2020/04/04 21:13:20 christos Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_BYTE_SWAP_H_
33#define _RISCV_BYTE_SWAP_H_
34
35#ifdef _LOCORE
36
37#define BSWAP16(_src, _dst, _tmp) \
38 andi _dst, _src, 0xff ;\
39 slli _dst, _dst, 8 ;\
40 srli _tmp, _src, 8 ;\
41 and _tmp, _tmp, 0xff ;\
42 ori _dst, _dst, _tmp
43
44#define BSWAP32(_src, _dst, _tmp) \
45 li v1, 0xff00 ;\
46 slli _dst, _src, 24 ;\
47 srli _tmp, _src, 24 ;\
48 ori _dst, _dst, _tmp ;\
49 and _tmp, _src, v1 ;\
50 slli _tmp, _src, 8 ;\
51 ori _dst, _dst, _tmp ;\
52 srli _tmp, _src, 8 ;\
53 and _tmp, _tmp, v1 ;\
54 ori _dst, _dst, _tmp
55
56#else
57
58#include <sys/types.h>
59__BEGIN_DECLS
60
61#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable
62static __inline uint64_t
63__byte_swap_u64_variable(uint64_t v)
64{
65 const uint64_t m1 = 0x0000ffff0000ffffull;
66 const uint64_t m0 = 0x00ff00ff00ff00ffull;
67
68 v = (v >> 32) | (v << 32);
69 v = ((v >> 16) & m1) | ((v & m1) << 16);
70 v = ((v >> 8) & m0) | ((v & m0) << 8);
71
72 return v;
73}
74
75#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
76static __inline uint32_t
77__byte_swap_u32_variable(uint32_t v)
78{
79 const uint32_t m = 0xff00ff;
80
81 v = (v >> 16) | (v << 16);
82 v = ((v >> 8) & m) | ((v & m) << 8);
83
84 return v;
85}
86
87#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable
88static __inline uint16_t
89__byte_swap_u16_variable(uint16_t v)
90{
91 /*LINTED*/
92 return (uint16_t)((v >> 8) | (v << 8));
93}
94
95__END_DECLS
96
97#endif /* _LOCORE */
98
99#endif /* _RISCV_BYTE_SWAP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/cdefs.h deleted-8
......@@ -1,8 +0,0 @@
1/* $NetBSD: cdefs.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#ifndef _RISCV_CDEFS_H_
4#define _RISCV_CDEFS_H_
5
6#define __ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1U)
7
8#endif /* _RISCV_CDEFS_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/cpu.h deleted-153
......@@ -1,153 +0,0 @@
1/* $NetBSD: cpu.h,v 1.9 2022/11/17 09:50:23 simonb Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_CPU_H_
33#define _RISCV_CPU_H_
34
35#if defined(_KERNEL) || defined(_KMEMUSER)
36
37struct clockframe {
38 vaddr_t cf_epc;
39 register_t cf_status;
40 int cf_intr_depth;
41};
42
43#define CLKF_USERMODE(cf) (((cf)->cf_status & SR_SPP) == 0)
44#define CLKF_PC(cf) ((cf)->cf_epc)
45#define CLKF_INTR(cf) ((cf)->cf_intr_depth > 0)
46
47#include <sys/cpu_data.h>
48#include <sys/device_if.h>
49#include <sys/evcnt.h>
50#include <sys/intr.h>
51
52struct cpu_info {
53 struct cpu_data ci_data;
54 device_t ci_dev;
55 cpuid_t ci_cpuid;
56 struct lwp *ci_curlwp;
57 struct lwp *ci_onproc; /* current user LWP / kthread */
58 struct lwp *ci_softlwps[SOFTINT_COUNT];
59 struct trapframe *ci_ddb_regs;
60
61 uint64_t ci_lastintr;
62
63 int ci_mtx_oldspl;
64 int ci_mtx_count;
65
66 int ci_want_resched;
67 int ci_cpl;
68 u_int ci_softints;
69 volatile u_int ci_intr_depth;
70
71 tlb_asid_t ci_pmap_asid_cur;
72
73 union pmap_segtab *ci_pmap_user_segtab;
74#ifdef _LP64
75 union pmap_segtab *ci_pmap_user_seg0tab;
76#endif
77
78 struct evcnt ci_ev_fpu_saves;
79 struct evcnt ci_ev_fpu_loads;
80 struct evcnt ci_ev_fpu_reenables;
81#if defined(GPROF) && defined(MULTIPROCESSOR)
82 struct gmonparam *ci_gmon; /* MI per-cpu GPROF */
83#endif
84};
85
86#endif /* _KERNEL || _KMEMUSER */
87
88#ifdef _KERNEL
89
90extern struct cpu_info cpu_info_store;
91
92// This is also in <sys/lwp.h>
93struct lwp;
94static inline struct cpu_info *lwp_getcpu(struct lwp *);
95
96register struct lwp *riscv_curlwp __asm("tp");
97#define curlwp riscv_curlwp
98#define curcpu() lwp_getcpu(curlwp)
99
100static inline cpuid_t
101cpu_number(void)
102{
103#ifdef MULTIPROCESSOR
104 return curcpu()->ci_cpuid;
105#else
106 return 0;
107#endif
108}
109
110void cpu_proc_fork(struct proc *, struct proc *);
111void cpu_signotify(struct lwp *);
112void cpu_need_proftick(struct lwp *l);
113void cpu_boot_secondary_processors(void);
114
115#define CPU_INFO_ITERATOR cpuid_t
116#ifdef MULTIPROCESSOR
117#define CPU_INFO_FOREACH(cii, ci) \
118 (cii) = 0; ((ci) = cpu_infos[cii]) != NULL; (cii)++
119#else
120#define CPU_INFO_FOREACH(cii, ci) \
121 (cii) = 0, (ci) = curcpu(); (cii) == 0; (cii)++
122#endif
123
124#define CPU_INFO_CURPMAP(ci) (curlwp->l_proc->p_vmspace->vm_map.pmap)
125
126static inline void
127cpu_dosoftints(void)
128{
129 extern void dosoftints(void);
130 struct cpu_info * const ci = curcpu();
131 if (ci->ci_intr_depth == 0
132 && (ci->ci_data.cpu_softints >> ci->ci_cpl) > 0)
133 dosoftints();
134}
135
136static inline bool
137cpu_intr_p(void)
138{
139 return curcpu()->ci_intr_depth > 0;
140}
141
142#define LWP_PC(l) cpu_lwp_pc(l)
143
144vaddr_t cpu_lwp_pc(struct lwp *);
145
146static inline void
147cpu_idle(void)
148{
149}
150
151#endif /* _KERNEL */
152
153#endif /* _RISCV_CPU_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/disklabel.h deleted-68
......@@ -1,68 +0,0 @@
1/* $NetBSD: disklabel.h,v 1.2 2022/05/24 19:37:39 andvar Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_DISKLABEL_H_
33#define _RISCV_DISKLABEL_H_
34
35#define LABELUSESMBR 1 /* use MBR partitionning */
36#define LABELSECTOR 1 /* sector containing label */
37#define LABELOFFSET 0 /* offset of label in sector */
38#define MAXPARTITIONS 16 /* number of partitions */
39#define RAW_PART 2 /* raw partition: XX?c */
40
41#if HAVE_NBTOOL_CONFIG_H
42#include <nbinclude/sys/dkbad.h>
43#include <nbinclude/sys/bootblock.h>
44#else
45#include <sys/dkbad.h>
46#include <sys/bootblock.h>
47#endif /* HAVE_NBTOOL_CONFIG_H */
48
49struct cpu_disklabel {
50 struct mbr_partition mbrparts[MBR_PART_COUNT];
51#define __HAVE_DISKLABEL_DKBAD
52 struct dkbad bad;
53};
54
55#ifdef _KERNEL
56struct buf;
57struct disklabel;
58
59/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */
60int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *,
61 struct cpu_disklabel *, const char **, int *, int *);
62
63/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */
64int mbr_label_locate(dev_t, void (*)(struct buf *),
65 struct disklabel *, struct cpu_disklabel *, int *, int *);
66#endif /* _KERNEL */
67
68#endif /* _RISCV_DISKLABEL_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/elf_machdep.h deleted-144
......@@ -1,144 +0,0 @@
1/* $NetBSD: elf_machdep.h,v 1.9 2022/12/03 08:54:38 skrll Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_ELF_MACHDEP_H_
33#define _RISCV_ELF_MACHDEP_H_
34
35#define ELF32_MACHDEP_ID EM_RISCV
36#define ELF64_MACHDEP_ID EM_RISCV
37
38#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
39#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB
40
41#define ELF32_MACHDEP_ID_CASES \
42 case EM_RISCV: \
43 break;
44
45#define ELF64_MACHDEP_ID_CASES \
46 case EM_RISCV: \
47 break;
48
49#ifdef _LP64
50#define KERN_ELFSIZE 64
51#define ARCH_ELFSIZE 64 /* MD native binary size */
52#else
53#define KERN_ELFSIZE 32
54#define ARCH_ELFSIZE 32 /* MD native binary size */
55#endif
56
57/* Processor specific flags for the ELF header e_flags field. */
58
59/* Processor specific relocation types */
60
61#define R_RISCV_NONE 0
62#define R_RISCV_32 1 // A
63#define R_RISCV_64 2
64#define R_RISCV_RELATIVE 3
65#define R_RISCV_COPY 4
66#define R_RISCV_JMP_SLOT 5
67#define R_RISCV_TLS_DTPMOD32 6
68#define R_RISCV_TLS_DTPMOD64 7
69#define R_RISCV_TLS_DTPREL32 8
70#define R_RISCV_TLS_DTPREL64 9
71#define R_RISCV_TLS_TPREL32 10
72#define R_RISCV_TLS_TPREL64 11
73
74/* The rest are not used by the dynamic linker */
75#define R_RISCV_BRANCH 16 // (A - P) & 0xffff
76#define R_RISCV_JAL 17 // A & 0xff
77#define R_RISCV_CALL 18 // (A - P) & 0xff
78#define R_RISCV_CALL_PLT 19
79#define R_RISCV_GOT_HI20 20
80#define R_RISCV_TLS_GOT_HI20 21
81#define R_RISCV_TLS_GD_HI20 22
82#define R_RISCV_PCREL_HI20 23
83#define R_RISCV_PCREL_LO12_I 24
84#define R_RISCV_PCREL_LO12_S 25
85#define R_RISCV_HI20 26 // A & 0xffff
86#define R_RISCV_LO12_I 27 // (A >> 16) & 0xffff
87#define R_RISCV_LO12_S 28 // (S + A - P) >> 2
88#define R_RISCV_TPREL_HI20 29
89#define R_RISCV_TPREL_LO12_I 30
90#define R_RISCV_TPREL_LO12_S 31
91#define R_RISCV_TPREL_ADD 32
92#define R_RISCV_ADD8 33
93#define R_RISCV_ADD16 34
94#define R_RISCV_ADD32 35
95#define R_RISCV_ADD64 36
96#define R_RISCV_SUB8 37
97#define R_RISCV_SUB16 38
98#define R_RISCV_SUB32 39
99#define R_RISCV_SUB64 40
100#define R_RISCV_GNU_VTINHERIT 41 // A & 0xffff
101#define R_RISCV_GNU_VTENTRY 42
102#define R_RISCV_ALIGN 43
103#define R_RISCV_RVC_BRANCH 44
104#define R_RISCV_RVC_JUMP 45
105#define R_RISCV_RVC_LUI 46
106#define R_RISCV_GPREL_I 47
107#define R_RISCV_GPREL_S 48
108#define R_RISCV_TPREL_I 49
109#define R_RISCV_TPREL_S 50
110#define R_RISCV_RELAX 51
111#define R_RISCV_SUB6 52
112#define R_RISCV_SET6 53
113#define R_RISCV_SET8 54
114#define R_RISCV_SET16 55
115#define R_RISCV_SET32 56
116#define R_RISCV_32_PCREL 57
117
118/* These are aliases we can use R_TYPESZ */
119#define R_RISCV_ADDR32 R_RISCV_32
120#define R_RISCV_ADDR64 R_RISCV_64
121
122#define R_TYPE(name) R_RISCV_ ## name
123#if ELFSIZE == 32
124#define R_TYPESZ(name) R_RISCV_ ## name ## 32
125#else
126#define R_TYPESZ(name) R_RISCV_ ## name ## 64
127#endif
128
129#ifdef _KERNEL
130#ifdef ELFSIZE
131#define ELF_MD_PROBE_FUNC ELFNAME2(cpu_netbsd,probe)
132#endif
133
134struct exec_package;
135
136int cpu_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
137 vaddr_t *);
138
139int cpu_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
140 vaddr_t *);
141
142#endif /* _KERNEL */
143
144#endif /* _RISCV_ELF_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/endian.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: endian.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#include <sys/endian.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/endian_machdep.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: endian_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#define _BYTE_ORDER _LITTLE_ENDIAN
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/fenv.h deleted-35
......@@ -1,35 +0,0 @@
1/* $NetBSD: fenv.h,v 1.3 2020/03/14 16:12:16 skrll Exp $ */
2
3/*
4 * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
5 * Public domain.
6 */
7
8#ifndef _RISCV_FENV_H_
9#define _RISCV_FENV_H_
10
11typedef int fenv_t; /* FPSCR */
12typedef int fexcept_t;
13
14#define FE_INEXACT 0x00 /* Result inexact */
15#define FE_UNDERFLOW 0x02 /* Result underflowed */
16#define FE_OVERFLOW 0x04 /* Result overflowed */
17#define FE_DIVBYZERO 0x08 /* divide-by-zero */
18#define FE_INVALID 0x10 /* Result invalid */
19
20#define FE_ALL_EXCEPT 0x1f
21
22#define FE_TONEAREST 0 /* round to nearest representable number */
23#define FE_TOWARDZERO 1 /* round to zero (truncate) */
24#define FE_DOWNWARD 2 /* round toward negative infinity */
25#define FE_UPWARD 3 /* round toward positive infinity */
26
27__BEGIN_DECLS
28
29/* Default floating-point environment */
30extern const fenv_t __fe_dfl_env;
31#define FE_DFL_ENV (&__fe_dfl_env)
32
33__END_DECLS
34
35#endif /* _RISCV_FENV_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/float.h deleted-58
......@@ -1,58 +0,0 @@
1/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_FLOAT_H_
33#define _RISCV_FLOAT_H_
34
35#include <sys/cdefs.h>
36
37#define LDBL_MANT_DIG __LDBL_MANT_DIG__
38#define LDBL_DIG __LDBL_DIG__
39#define LDBL_MIN_EXP __LDBL_MIN_EXP__
40#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
41#define LDBL_MAX_EXP __LDBL_MAX_EXP__
42#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
43#define LDBL_EPSILON __LDBL_EPSILON__
44#define LDBL_MIN __LDBL_MIN__
45#define LDBL_MAX __LDBL_MAX__
46
47#include <sys/float_ieee754.h>
48
49#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \
50 && !defined(_XOPEN_SOURCE)) \
51 || (__STDC_VERSION__ - 0) >= 199901L \
52 || (_POSIX_C_SOURCE - 0) >= 200112L \
53 || ((_XOPEN_SOURCE - 0) >= 600) \
54 || defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
55#define DECIMAL_DIG __DECIMAL_DIG__
56#endif
57
58#endif /* !_RISCV_FLOAT_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/ieee.h deleted-4
......@@ -1,4 +0,0 @@
1/* $NetBSD: ieee.h,v 1.2 2019/04/13 15:57:31 maya Exp $ */
2
3#include <riscv/math.h> /* for #define __HAVE_LONG_DOUBLE 128 */
4#include <sys/ieee754.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/ieeefp.h deleted-44
......@@ -1,44 +0,0 @@
1/* $NetBSD: ieeefp.h,v 1.2 2020/03/14 16:12:16 skrll Exp $ */
2
3/*
4 * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
5 * Public domain.
6 */
7
8#ifndef _RISCV_IEEEFP_H_
9#define _RISCV_IEEEFP_H_
10
11#include <sys/featuretest.h>
12
13#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
14
15#include <riscv/fenv.h>
16
17#if !defined(_ISOC99_SOURCE)
18
19/* Exception type (used by fpsetmask() et al.) */
20
21typedef int fp_except;
22
23/* Bit defines for fp_except */
24
25#define FP_X_INV FE_INVALID /* invalid operation exception */
26#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */
27#define FP_X_OFL FE_OVERFLOW /* overflow exception */
28#define FP_X_UFL FE_UNDERFLOW /* underflow exception */
29#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */
30
31/* Rounding modes */
32
33typedef enum {
34 FP_RN=FE_TONEAREST, /* round to nearest representable number */
35 FP_RP=FE_UPWARD, /* round toward positive infinity */
36 FP_RM=FE_DOWNWARD, /* round toward negative infinity */
37 FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */
38} fp_rnd;
39
40#endif /* !_ISOC99_SOURCE */
41
42#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
43
44#endif /* _RISCV_IEEEFP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/int_const.h deleted-20
......@@ -1,20 +0,0 @@
1/* $NetBSD: int_const.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#ifndef __INTMAX_C_SUFFIX__
4
5#define __INT8_C_SUFFIX__
6#define __INT16_C_SUFFIX__
7#define __INT32_C_SUFFIX__
8#define __INT64_C_SUFFIX__ LL
9
10#define __UINT8_C_SUFFIX__
11#define __UINT16_C_SUFFIX__
12#define __UINT32_C_SUFFIX__
13#define __UINT64_C_SUFFIX__ ULL
14
15#define __INTMAX_C_SUFFIX__ LL
16#define __UINTMAX_C_SUFFIX__ ULL
17
18#endif
19
20#include <sys/common_int_const.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/int_fmtio.h deleted-381
......@@ -1,381 +0,0 @@
1/* $NetBSD: int_fmtio.h,v 1.4 2019/04/17 11:01:19 mrg Exp $ */
2
3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_INT_FMTIO_H_
33#define _RISCV_INT_FMTIO_H_
34
35#ifdef __INTPTR_FMTd__
36#include <sys/common_int_fmtio.h>
37#else
38/*
39 * 7.8.1 Macros for format specifiers
40 */
41
42/* fprintf macros for signed integers */
43#define PRId8 "hhd" /* int8_t */
44#define PRId16 "hd" /* int16_t */
45#define PRId32 "d" /* int32_t */
46#ifdef _LP64
47#define PRId64 "ld" /* int64_t */
48#else
49#define PRId64 "lld" /* int64_t */
50#endif
51#define PRIdLEAST8 "hhd" /* int_least8_t */
52#define PRIdLEAST16 "hd" /* int_least16_t */
53#define PRIdLEAST32 "d" /* int_least32_t */
54#ifdef _LP64
55#define PRIdLEAST64 "ld" /* int_least64_t */
56#define PRIdFAST8 "d" /* int_fast8_t */
57#define PRIdFAST16 "d" /* int_fast16_t */
58#else
59#define PRIdLEAST64 "lld" /* int_least64_t */
60#define PRIdFAST8 "hhd" /* int_fast8_t */
61#define PRIdFAST16 "hd" /* int_fast16_t */
62#endif
63#define PRIdFAST32 "d" /* int_fast32_t */
64#ifdef _LP64
65#define PRIdFAST64 "ld" /* int_fast64_t */
66#define PRIdMAX "ld" /* intmax_t */
67#else
68#define PRIdFAST64 "lld" /* int_fast64_t */
69#define PRIdMAX "lld" /* intmax_t */
70#endif
71#define PRIdPTR "ld" /* intptr_t */
72
73#define PRIi8 "hhi" /* int8_t */
74#define PRIi16 "hi" /* int16_t */
75#define PRIi32 "i" /* int32_t */
76#ifdef _LP64
77#define PRIi64 "li" /* int64_t */
78#else
79#define PRIi64 "lli" /* int64_t */
80#endif
81#define PRIiLEAST8 "hhi" /* int_least8_t */
82#define PRIiLEAST16 "hi" /* int_least16_t */
83#define PRIiLEAST32 "i" /* int_least32_t */
84#ifdef _LP64
85#define PRIiLEAST64 "li" /* int_least64_t */
86#define PRIiFAST8 "i" /* int_fast8_t */
87#define PRIiFAST16 "i" /* int_fast16_t */
88#else
89#define PRIiLEAST64 "lli" /* int_least64_t */
90#define PRIiFAST8 "hhi" /* int_fast8_t */
91#define PRIiFAST16 "hi" /* int_fast16_t */
92#endif
93#define PRIiFAST32 "i" /* int_fast32_t */
94#ifdef _LP64
95#define PRIiFAST64 "li" /* int_fast64_t */
96#define PRIiMAX "li" /* intmax_t */
97#else
98#define PRIiFAST64 "lli" /* int_fast64_t */
99#define PRIiMAX "lli" /* intmax_t */
100#endif
101#define PRIiPTR "li" /* intptr_t */
102
103/* fprintf macros for unsigned integers */
104
105#define PRIo8 "hho" /* uint8_t */
106#define PRIo16 "ho" /* uint16_t */
107#define PRIo32 "o" /* uint32_t */
108#ifdef _LP64
109#define PRIo64 "lo" /* uint64_t */
110#else
111#define PRIo64 "llo" /* uint64_t */
112#endif
113#define PRIoLEAST8 "o" /* uint_least8_t */
114#define PRIoLEAST16 "hho" /* uint_least16_t */
115#define PRIoLEAST32 "ho" /* uint_least32_t */
116#ifdef _LP64
117#define PRIoLEAST64 "lo" /* uint_least64_t */
118#define PRIoFAST8 "o" /* uint_fast8_t */
119#define PRIoFAST16 "o" /* uint_fast16_t */
120#else
121#define PRIoLEAST64 "llo" /* uint_least64_t */
122#define PRIoFAST8 "hho" /* uint_fast8_t */
123#define PRIoFAST16 "ho" /* uint_fast16_t */
124#endif
125#define PRIoFAST32 "o" /* uint_fast32_t */
126#ifdef _LP64
127#define PRIoFAST64 "lo" /* uint_fast64_t */
128#define PRIoMAX "lo" /* uintmax_t */
129#else
130#define PRIoFAST64 "llo" /* uint_fast64_t */
131#define PRIoMAX "llo" /* uintmax_t */
132#endif
133#define PRIoPTR "lo" /* uintptr_t */
134
135#define PRIu8 "hhu" /* uint8_t */
136#define PRIu16 "hu" /* uint16_t */
137#define PRIu32 "u" /* uint32_t */
138#ifdef _LP64
139#define PRIu64 "lu" /* uint64_t */
140#else
141#define PRIu64 "llu" /* uint64_t */
142#endif
143#define PRIuLEAST8 "hhu" /* uint_least8_t */
144#define PRIuLEAST16 "hu" /* uint_least16_t */
145#define PRIuLEAST32 "u" /* uint_least32_t */
146#ifdef _LP64
147#define PRIuLEAST64 "lu" /* uint_least64_t */
148#define PRIuFAST8 "u" /* uint_fast8_t */
149#define PRIuFAST16 "u" /* uint_fast16_t */
150#else
151#define PRIuLEAST64 "llu" /* uint_least64_t */
152#define PRIuFAST8 "hhu" /* uint_fast8_t */
153#define PRIuFAST16 "hu" /* uint_fast16_t */
154#endif
155#define PRIuFAST32 "u" /* uint_fast32_t */
156#ifdef _LP64
157#define PRIuFAST64 "lu" /* uint_fast64_t */
158#define PRIuMAX "lu" /* uintmax_t */
159#else
160#define PRIuFAST64 "llu" /* uint_fast64_t */
161#define PRIuMAX "llu" /* uintmax_t */
162#endif
163#define PRIuPTR "lu" /* uintptr_t */
164
165#define PRIx8 "hhx" /* uint8_t */
166#define PRIx16 "hx" /* uint16_t */
167#define PRIx32 "x" /* uint32_t */
168#ifdef _LP64
169#define PRIx64 "lx" /* uint64_t */
170#else
171#define PRIx64 "llx" /* uint64_t */
172#endif
173#define PRIxLEAST8 "x" /* uint_least8_t */
174#define PRIxLEAST16 "x" /* uint_least16_t */
175#define PRIxLEAST32 "x" /* uint_least32_t */
176#ifdef _LP64
177#define PRIxLEAST64 "lx" /* uint_least64_t */
178#define PRIxFAST8 "x" /* uint_fast8_t */
179#define PRIxFAST16 "x" /* uint_fast16_t */
180#else
181#define PRIxLEAST64 "llx" /* uint_least64_t */
182#define PRIxFAST8 "hhx" /* uint_fast8_t */
183#define PRIxFAST16 "hx" /* uint_fast16_t */
184#endif
185#define PRIxFAST32 "x" /* uint_fast32_t */
186#ifdef _LP64
187#define PRIxFAST64 "lx" /* uint_fast64_t */
188#define PRIxMAX "lx" /* uintmax_t */
189#else
190#define PRIxFAST64 "llx" /* uint_fast64_t */
191#define PRIxMAX "llx" /* uintmax_t */
192#endif
193#define PRIxPTR "lx" /* uintptr_t */
194
195#define PRIX8 "hhX" /* uint8_t */
196#define PRIX16 "hX" /* uint16_t */
197#define PRIX32 "X" /* uint32_t */
198#ifdef _LP64
199#define PRIX64 "lX" /* uint64_t */
200#else
201#define PRIX64 "llX" /* uint64_t */
202#endif
203#define PRIXLEAST8 "X" /* uint_least8_t */
204#define PRIXLEAST16 "X" /* uint_least16_t */
205#define PRIXLEAST32 "X" /* uint_least32_t */
206#ifdef _LP64
207#define PRIXLEAST64 "lX" /* uint_least64_t */
208#define PRIXFAST8 "X" /* uint_fast8_t */
209#define PRIXFAST16 "X" /* uint_fast16_t */
210#else
211#define PRIXLEAST64 "llX" /* uint_least64_t */
212#define PRIXFAST8 "hhX" /* uint_fast8_t */
213#define PRIXFAST16 "hX" /* uint_fast16_t */
214#endif
215#define PRIXFAST32 "X" /* uint_fast32_t */
216#ifdef _LP64
217#define PRIXFAST64 "lX" /* uint_fast64_t */
218#define PRIXMAX "lX" /* uintmax_t */
219#else
220#define PRIXFAST64 "llX" /* uint_fast64_t */
221#define PRIXMAX "llX" /* uintmax_t */
222#endif
223#define PRIXPTR "lX" /* uintptr_t */
224
225/* fscanf macros for signed integers */
226
227#define SCNd8 "hhd" /* int8_t */
228#define SCNd16 "hd" /* int16_t */
229#define SCNd32 "d" /* int32_t */
230#ifdef _LP64
231#define SCNd64 "ld" /* int64_t */
232#else
233#define SCNd64 "lld" /* int64_t */
234#endif
235#define SCNdLEAST8 "hhd" /* int_least8_t */
236#define SCNdLEAST16 "hd" /* int_least16_t */
237#define SCNdLEAST32 "d" /* int_least32_t */
238#ifdef _LP64
239#define SCNdLEAST64 "ld" /* int_least64_t */
240#define SCNdFAST8 "d" /* int_fast8_t */
241#define SCNdFAST16 "d" /* int_fast16_t */
242#else
243#define SCNdLEAST64 "lld" /* int_least64_t */
244#define SCNdFAST8 "hhd" /* int_fast8_t */
245#define SCNdFAST16 "hd" /* int_fast16_t */
246#endif
247#define SCNdFAST32 "d" /* int_fast32_t */
248#ifdef _LP64
249#define SCNdFAST64 "ld" /* int_fast64_t */
250#define SCNdMAX "ld" /* intmax_t */
251#else
252#define SCNdFAST64 "lld" /* int_fast64_t */
253#define SCNdMAX "lld" /* intmax_t */
254#endif
255#define SCNdPTR "ld" /* intptr_t */
256
257#define SCNi8 "hhi" /* int8_t */
258#define SCNi16 "hi" /* int16_t */
259#define SCNi32 "i" /* int32_t */
260#ifdef _LP64
261#define SCNi64 "li" /* int64_t */
262#else
263#define SCNi64 "lli" /* int64_t */
264#endif
265#define SCNiLEAST8 "hhi" /* int_least8_t */
266#define SCNiLEAST16 "hi" /* int_least16_t */
267#define SCNiLEAST32 "i" /* int_least32_t */
268#ifdef _LP64
269#define SCNiLEAST64 "li" /* int_least64_t */
270#define SCNiFAST8 "i" /* int_fast8_t */
271#define SCNiFAST16 "i" /* int_fast16_t */
272#else
273#define SCNiLEAST64 "lli" /* int_least64_t */
274#define SCNiFAST8 "hhi" /* int_fast8_t */
275#define SCNiFAST16 "hi" /* int_fast16_t */
276#endif
277#define SCNiFAST32 "i" /* int_fast32_t */
278#ifdef _LP64
279#define SCNiFAST64 "li" /* int_fast64_t */
280#define SCNiMAX "li" /* intmax_t */
281#else
282#define SCNiFAST64 "lli" /* int_fast64_t */
283#define SCNiMAX "lli" /* intmax_t */
284#endif
285#define SCNiPTR "li" /* intptr_t */
286
287/* fscanf macros for unsigned integers */
288
289#define SCNo8 "hho" /* uint8_t */
290#define SCNo16 "ho" /* uint16_t */
291#define SCNo32 "o" /* uint32_t */
292#ifdef _LP64
293#define SCNo64 "lo" /* uint64_t */
294#else
295#define SCNo64 "llo" /* uint64_t */
296#endif
297#define SCNoLEAST8 "hho" /* uint_least8_t */
298#define SCNoLEAST16 "ho" /* uint_least16_t */
299#define SCNoLEAST32 "o" /* uint_least32_t */
300#ifdef _LP64
301#define SCNoLEAST64 "lo" /* uint_least64_t */
302#define SCNoFAST8 "o" /* uint_fast8_t */
303#define SCNoFAST16 "o" /* uint_fast16_t */
304#else
305#define SCNoLEAST64 "llo" /* uint_least64_t */
306#define SCNoFAST8 "hho" /* uint_fast8_t */
307#define SCNoFAST16 "ho" /* uint_fast16_t */
308#endif
309#define SCNoFAST32 "o" /* uint_fast32_t */
310#ifdef _LP64
311#define SCNoFAST64 "lo" /* uint_fast64_t */
312#define SCNoMAX "lo" /* uintmax_t */
313#else
314#define SCNoFAST64 "llo" /* uint_fast64_t */
315#define SCNoMAX "llo" /* uintmax_t */
316#endif
317#define SCNoPTR "lo" /* uintptr_t */
318
319#define SCNu8 "hhu" /* uint8_t */
320#define SCNu16 "hu" /* uint16_t */
321#define SCNu32 "u" /* uint32_t */
322#ifdef _LP64
323#define SCNu64 "lu" /* uint64_t */
324#else
325#define SCNu64 "llu" /* uint64_t */
326#endif
327#define SCNuLEAST8 "hhu" /* uint_least8_t */
328#define SCNuLEAST16 "hu" /* uint_least16_t */
329#define SCNuLEAST32 "u" /* uint_least32_t */
330#ifdef _LP64
331#define SCNuLEAST64 "lu" /* uint_least64_t */
332#define SCNuFAST8 "u" /* uint_fast8_t */
333#define SCNuFAST16 "u" /* uint_fast16_t */
334#else
335#define SCNuLEAST64 "llu" /* uint_least64_t */
336#define SCNuFAST8 "hhu" /* uint_fast8_t */
337#define SCNuFAST16 "hu" /* uint_fast16_t */
338#endif
339#define SCNuFAST32 "u" /* uint_fast32_t */
340#ifdef _LP64
341#define SCNuFAST64 "lu" /* uint_fast64_t */
342#define SCNuMAX "lu" /* uintmax_t */
343#else
344#define SCNuFAST64 "llu" /* uint_fast64_t */
345#define SCNuMAX "llu" /* uintmax_t */
346#endif
347#define SCNuPTR "lu" /* uintptr_t */
348
349#define SCNx8 "hhx" /* uint8_t */
350#define SCNx16 "hx" /* uint16_t */
351#define SCNx32 "x" /* uint32_t */
352#ifdef _LP64
353#define SCNx64 "lx" /* uint64_t */
354#else
355#define SCNx64 "llx" /* uint64_t */
356#endif
357#define SCNxLEAST8 "hhx" /* uint_least8_t */
358#define SCNxLEAST16 "hx" /* uint_least16_t */
359#define SCNxLEAST32 "x" /* uint_least32_t */
360#ifdef _LP64
361#define SCNxLEAST64 "lx" /* uint_least64_t */
362#define SCNxFAST8 "x" /* uint_fast8_t */
363#define SCNxFAST16 "x" /* uint_fast16_t */
364#else
365#define SCNxLEAST64 "llx" /* uint_least64_t */
366#define SCNxFAST8 "hhx" /* uint_fast8_t */
367#define SCNxFAST16 "hx" /* uint_fast16_t */
368#endif
369#define SCNxFAST32 "x" /* uint_fast32_t */
370#ifdef _LP64
371#define SCNxFAST64 "lx" /* uint_fast64_t */
372#define SCNxMAX "lx" /* uintmax_t */
373#else
374#define SCNxFAST64 "llx" /* uint_fast64_t */
375#define SCNxMAX "llx" /* uintmax_t */
376#endif
377#define SCNxPTR "lx" /* uintptr_t */
378
379#endif /* !__INTPTR_FMTd__ */
380
381#endif /* !_RISCV_INT_FMTIO_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/int_limits.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: int_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#include <sys/common_int_limits.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/int_mwgwtypes.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#include <sys/common_int_mwgwtypes.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/int_types.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: int_types.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#include <sys/common_int_types.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/kcore.h deleted-40
......@@ -1,40 +0,0 @@
1/* $NetBSD: kcore.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_KCORE_H_
33#define _RISCV_KCORE_H_
34
35typedef struct cpu_kcore_hdr {
36 uint64_t kh_misc[8];
37 phys_ram_seg_t kh_ramsegs[0];
38} cpu_kcore_hdr_t;
39
40#endif /* _RISCV_KCORE_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/limits.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#include <sys/common_limits.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/lock.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: lock.h,v 1.4 2015/06/26 14:27:35 matt Exp $ */
2
3#include <sys/common_lock.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/math.h deleted-4
......@@ -1,4 +0,0 @@
1/* $NetBSD: math.h,v 1.3 2019/04/16 07:40:02 maya Exp $ */
2
3#define __HAVE_NANF
4#define __HAVE_LONG_DOUBLE 128
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/mcontext.h deleted-170
......@@ -1,170 +0,0 @@
1/* $NetBSD: mcontext.h,v 1.6 2020/03/14 16:12:16 skrll Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31#ifndef _RISCV_MCONTEXT_H_
32#define _RISCV_MCONTEXT_H_
33
34/*
35 */
36
37#define _NGREG 32 /* GR1-31 */
38#define _NFREG 33 /* F0-31, FCSR */
39
40/*
41 * This fragment is common to <riscv/mcontext.h> and <riscv/reg.h>
42 */
43#ifndef _BSD_FPREG_T_
44union __fpreg {
45 __uint64_t u_u64;
46 double u_d;
47};
48#define _BSD_FPREG_T_ union __fpreg
49#endif
50
51typedef __uint64_t __greg_t;
52typedef __greg_t __gregset_t[_NGREG];
53typedef __uint32_t __greg32_t;
54typedef __greg32_t __gregset32_t[_NGREG];
55typedef _BSD_FPREG_T_ __fregset_t[_NFREG];
56
57#define _REG_X1 0
58#define _REG_X2 1
59#define _REG_X3 2
60#define _REG_X4 3
61#define _REG_X5 4
62#define _REG_X6 5
63#define _REG_X7 6
64#define _REG_X8 7
65#define _REG_X9 8
66#define _REG_X10 9
67#define _REG_X11 10
68#define _REG_X12 11
69#define _REG_X13 12
70#define _REG_X14 13
71#define _REG_X15 14
72#define _REG_X16 15
73#define _REG_X17 16
74#define _REG_X18 17
75#define _REG_X19 18
76#define _REG_X20 19
77#define _REG_X21 20
78#define _REG_X22 21
79#define _REG_X23 22
80#define _REG_X24 23
81#define _REG_X25 24
82#define _REG_X26 25
83#define _REG_X27 26
84#define _REG_X28 27
85#define _REG_X29 28
86#define _REG_X30 29
87#define _REG_X31 30
88#define _REG_PC 31
89
90#define _REG_RA _REG_X1
91#define _REG_SP _REG_X2
92#define _REG_GP _REG_X3
93#define _REG_TP _REG_X4
94#define _REG_S0 _REG_X8
95#define _REG_RV _REG_X10
96#define _REG_A0 _REG_X10
97
98#define _REG_F0 0
99#define _REG_FPCSR 32
100
101typedef struct {
102 __gregset_t __gregs; /* General Purpose Register set */
103 __fregset_t __fregs; /* Floating Point Register set */
104 __greg_t __private; /* copy of l_private */
105 __greg_t __spare[8]; /* future proof */
106} mcontext_t;
107
108typedef struct {
109 __gregset32_t __gregs; /* General Purpose Register set */
110 __fregset_t __fregs; /* Floating Point Register set */
111 __greg32_t __private; /* copy of l_private */
112 __greg32_t __spare[8]; /* future proof */
113} mcontext32_t;
114
115/* Machine-dependent uc_flags */
116#define _UC_SETSTACK 0x00010000 /* see <sys/ucontext.h> */
117#define _UC_CLRSTACK 0x00020000 /* see <sys/ucontext.h> */
118#define _UC_TLSBASE 0x00080000 /* see <sys/ucontext.h> */
119
120#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
121#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0])
122#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
123#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV])
124
125#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
126
127#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
128#include <sys/tls.h>
129
130/*
131 * On RISCV, since displacements are signed 12-bit values, the TCB pointer is
132 * not and points to the first static entry.
133 */
134#define TLS_TP_OFFSET 0x0
135#define TLS_DTV_OFFSET 0x800
136__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800);
137
138static __inline void *
139__lwp_getprivate_fast(void)
140{
141 void *__tp;
142 __asm("move %0,tp" : "=r"(__tp));
143 return __tp;
144}
145
146static __inline void *
147__lwp_gettcb_fast(void)
148{
149 void *__tcb;
150
151 __asm __volatile(
152 "addi %[__tcb],tp,%[__offset]"
153 : [__tcb] "=r" (__tcb)
154 : [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
155
156 return __tcb;
157}
158
159static __inline void
160__lwp_settcb(void *__tcb)
161{
162 __asm __volatile(
163 "addi tp,%[__tcb],%[__offset]"
164 :
165 : [__tcb] "r" (__tcb),
166 [__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
167}
168#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
169
170#endif /* !_RISCV_MCONTEXT_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/mutex.h deleted-124
......@@ -1,124 +0,0 @@
1/* $NetBSD: mutex.h,v 1.4.4.1 2023/08/09 17:42:03 martin Exp $ */
2
3/*-
4 * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_MUTEX_H_
33#define _RISCV_MUTEX_H_
34
35#include <sys/types.h>
36
37#ifndef __MUTEX_PRIVATE
38
39struct kmutex {
40 uintptr_t mtx_pad1;
41};
42
43#else /* __MUTEX_PRIVATE */
44
45#include <sys/cdefs.h>
46
47#include <sys/param.h>
48
49#include <machine/intr.h>
50
51struct kmutex {
52 volatile uintptr_t mtx_owner;
53};
54
55#ifdef _LP64
56#define MTX_ASMOP_SFX ".d" // doubleword atomic op
57#else
58#define MTX_ASMOP_SFX ".w" // word atomic op
59#endif
60
61#define MTX_LOCK __BIT(8) // just one bit
62#define MTX_IPL __BITS(7,4) // only need 4 bits
63
64#undef MUTEX_SPIN_IPL // override <sys/mutex.h>
65#define MUTEX_SPIN_IPL(a) riscv_mutex_spin_ipl(a)
66#define MUTEX_INITIALIZE_SPIN_IPL(a,b) riscv_mutex_initialize_spin_ipl(a,b)
67#define MUTEX_SPINBIT_LOCK_INIT(a) riscv_mutex_spinbit_lock_init(a)
68#define MUTEX_SPINBIT_LOCK_TRY(a) riscv_mutex_spinbit_lock_try(a)
69#define MUTEX_SPINBIT_LOCKED_P(a) riscv_mutex_spinbit_locked_p(a)
70#define MUTEX_SPINBIT_LOCK_UNLOCK(a) riscv_mutex_spinbit_lock_unlock(a)
71
72static inline ipl_cookie_t
73riscv_mutex_spin_ipl(kmutex_t *__mtx)
74{
75 return (ipl_cookie_t){._spl = __SHIFTOUT(__mtx->mtx_owner, MTX_IPL)};
76}
77
78static inline void
79riscv_mutex_initialize_spin_ipl(kmutex_t *__mtx, int ipl)
80{
81 __mtx->mtx_owner = (__mtx->mtx_owner & ~MTX_IPL)
82 | __SHIFTIN(ipl, MTX_IPL);
83}
84
85static inline void
86riscv_mutex_spinbit_lock_init(kmutex_t *__mtx)
87{
88 __mtx->mtx_owner &= ~MTX_LOCK;
89}
90
91static inline bool
92riscv_mutex_spinbit_locked_p(const kmutex_t *__mtx)
93{
94 return (__mtx->mtx_owner & MTX_LOCK) != 0;
95}
96
97static inline bool
98riscv_mutex_spinbit_lock_try(kmutex_t *__mtx)
99{
100 uintptr_t __old;
101 __asm __volatile(
102 "amoor" MTX_ASMOP_SFX ".aq\t%0, %1, (%2)"
103 : "=r"(__old)
104 : "r"(MTX_LOCK), "r"(__mtx));
105 return (__old & MTX_LOCK) == 0;
106}
107
108static inline void
109riscv_mutex_spinbit_lock_unlock(kmutex_t *__mtx)
110{
111 __asm __volatile(
112 "amoand" MTX_ASMOP_SFX ".rl\tx0, %0, (%1)"
113 :: "r"(~MTX_LOCK), "r"(__mtx));
114}
115
116#if 0
117#define __HAVE_MUTEX_STUBS 1
118#define __HAVE_SPIN_MUTEX_STUBS 1
119#endif
120#define __HAVE_SIMPLE_MUTEXES 1
121
122#endif /* __MUTEX_PRIVATE */
123
124#endif /* _RISCV_MUTEX_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/param.h deleted-106
......@@ -1,106 +0,0 @@
1/* $NetBSD: param.h,v 1.7 2022/10/12 07:50:00 simonb Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_PARAM_H_
33#define _RISCV_PARAM_H_
34
35#ifdef _KERNEL_OPT
36#include "opt_param.h"
37#endif
38
39/*
40 * Machine dependent constants for all OpenRISC processors
41 */
42
43/*
44 * For KERNEL code:
45 * MACHINE must be defined by the individual port. This is so that
46 * uname returns the correct thing, etc.
47 *
48 * For non-KERNEL code:
49 * If ELF, MACHINE and MACHINE_ARCH are forced to "or1k/or1k".
50 */
51
52#ifdef _LP64
53#define _MACHINE_ARCH riscv64
54#define MACHINE_ARCH "riscv64"
55#define _MACHINE_ARCH32 riscv32
56#define MACHINE_ARCH32 "riscv32"
57#else
58#define _MACHINE_ARCH riscv32
59#define MACHINE_ARCH "riscv32"
60#endif
61#define _MACHINE riscv
62#define MACHINE "riscv"
63
64#define MID_MACHINE MID_RISCV
65
66/* RISCV-specific macro to align a stack pointer (downwards). */
67#define STACK_ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1)
68#define ALIGNBYTES32 __BIGGEST_ALIGNMENT__
69
70#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT)
71#define NKMEMPAGES_MAX_UNLIMITED 1
72
73#define PGSHIFT 12
74#define NBPG (1 << PGSHIFT)
75#define PGOFSET (NBPG - 1)
76
77#define UPAGES 2
78#define USPACE (UPAGES << PGSHIFT)
79#define USPACE_ALIGN NBPG
80
81/*
82 * Constants related to network buffer management.
83 * MCLBYTES must be no larger than NBPG (the software page size), and
84 * NBPG % MCLBYTES must be zero.
85 */
86#define MSIZE 512 /* size of an mbuf */
87
88#ifndef MCLSHIFT
89#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
90 /* 2K cluster can hold Ether frame */
91#endif /* MCLSHIFT */
92
93#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
94
95#ifndef MSGBUFSIZE
96#define MSGBUFSIZE 65536 /* default message buffer size */
97#endif
98
99#define MAXCPUS 32
100
101#ifdef _KERNEL
102void delay(unsigned long);
103#define DELAY(x) delay(x)
104#endif
105
106#endif /* _RISCV_PARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/pcb.h deleted-46
......@@ -1,46 +0,0 @@
1/* $NetBSD: pcb.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_PCB_H_
33#define _RISCV_PCB_H_
34
35#include <riscv/reg.h>
36
37struct pcb {
38 struct fpreg pcb_fpregs;
39};
40
41struct md_coredump {
42 struct reg reg;
43 struct fpreg fpreg;
44};
45
46#endif /* _RISCV_PCB_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/pmap.h deleted-213
......@@ -1,213 +0,0 @@
1/* $NetBSD: pmap.h,v 1.13 2022/10/20 07:18:11 skrll Exp $ */
2
3/*
4 * Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas (of 3am Software Foundry), Maxime Villard, and
9 * Nick Hudson.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef _RISCV_PMAP_H_
34#define _RISCV_PMAP_H_
35
36#ifdef _KERNEL_OPT
37#include "opt_modular.h"
38#endif
39
40#if !defined(_MODULE)
41
42#include <sys/cdefs.h>
43#include <sys/types.h>
44#include <sys/pool.h>
45#include <sys/evcnt.h>
46
47#include <uvm/uvm_physseg.h>
48#include <uvm/pmap/vmpagemd.h>
49
50#include <riscv/pte.h>
51#include <riscv/sysreg.h>
52
53#define PMAP_SEGTABSIZE NPTEPG
54#define PMAP_PDETABSIZE NPTEPG
55
56#ifdef _LP64
57#define PTPSHIFT 3
58/* This is SV48. */
59//#define SEGLENGTH + SEGSHIFT + SEGSHIFT */
60
61/* This is SV39. */
62#define XSEGSHIFT (SEGSHIFT + SEGLENGTH)
63#define NBXSEG (1ULL << XSEGSHIFT)
64#define XSEGOFSET (NBXSEG - 1) /* byte offset into xsegment */
65#define XSEGLENGTH (PGSHIFT - 3)
66#define NXSEGPG (1 << XSEGLENGTH)
67#else
68#define PTPSHIFT 2
69#define XSEGSHIFT SEGSHIFT
70#endif
71
72#define SEGLENGTH (PGSHIFT - PTPSHIFT)
73#define SEGSHIFT (SEGLENGTH + PGSHIFT)
74#define NBSEG (1 << SEGSHIFT) /* bytes/segment */
75#define SEGOFSET (NBSEG - 1) /* byte offset into segment */
76
77#define KERNEL_PID 0
78
79#define PMAP_HWPAGEWALKER 1
80#define PMAP_TLB_MAX 1
81#ifdef _LP64
82#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE))
83#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE))
84#else
85#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)0xdeadbeef)
86#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)0xdeadbeef)
87#endif
88#define PMAP_TLB_NUM_PIDS (__SHIFTOUT_MASK(SATP_ASID) + 1)
89#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS
90#define PMAP_TLB_FLUSH_ASID_ON_RESET false
91
92#define pmap_phys_address(x) (x)
93
94#ifndef __BSD_PTENTRY_T__
95#define __BSD_PTENTRY_T__
96#ifdef _LP64
97#define PRIxPTE PRIx64
98#else
99#define PRIxPTE PRIx32
100#endif
101#endif /* __BSD_PTENTRY_T__ */
102
103#define PMAP_NEED_PROCWR
104static inline void
105pmap_procwr(struct proc *p, vaddr_t va, vsize_t len)
106{
107 __asm __volatile("fence\trw,rw; fence.i" ::: "memory");
108}
109
110#include <uvm/pmap/tlb.h>
111#include <uvm/pmap/pmap_tlb.h>
112
113#define PMAP_GROWKERNEL
114#define PMAP_STEAL_MEMORY
115
116#ifdef _KERNEL
117
118#define __HAVE_PMAP_MD
119struct pmap_md {
120 paddr_t md_ppn;
121 pd_entry_t *md_pdetab;
122};
123
124struct vm_page *
125 pmap_md_alloc_poolpage(int flags);
126vaddr_t pmap_md_map_poolpage(paddr_t, vsize_t);
127void pmap_md_unmap_poolpage(vaddr_t, vsize_t);
128bool pmap_md_direct_mapped_vaddr_p(vaddr_t);
129bool pmap_md_io_vaddr_p(vaddr_t);
130paddr_t pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t);
131vaddr_t pmap_md_direct_map_paddr(paddr_t);
132void pmap_md_init(void);
133
134void pmap_md_xtab_activate(struct pmap *, struct lwp *);
135void pmap_md_xtab_deactivate(struct pmap *);
136void pmap_md_pdetab_init(struct pmap *);
137bool pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t);
138
139void pmap_bootstrap(vaddr_t kstart, vaddr_t kend);
140
141extern vaddr_t pmap_direct_base;
142extern vaddr_t pmap_direct_end;
143#define PMAP_DIRECT_MAP(pa) (pmap_direct_base + (pa))
144#define PMAP_DIRECT_UNMAP(va) ((paddr_t)(va) - pmap_direct_base)
145
146#define MEGAPAGE_TRUNC(x) ((x) & ~SEGOFSET)
147#define MEGAPAGE_ROUND(x) MEGAPAGE_TRUNC((x) + SEGOFSET)
148
149#ifdef __PMAP_PRIVATE
150
151static inline bool
152pmap_md_tlb_check_entry(void *ctx, vaddr_t va, tlb_asid_t asid, pt_entry_t pte)
153{
154 // TLB not walked and so not called.
155 return false;
156}
157
158static inline void
159pmap_md_page_syncicache(struct vm_page_md *mdpg, const kcpuset_t *kc)
160{
161 __asm __volatile("fence\trw,rw; fence.i" ::: "memory");
162}
163
164/*
165 * Virtual Cache Alias helper routines. Not a problem for RISCV CPUs.
166 */
167static inline bool
168pmap_md_vca_add(struct vm_page_md *mdpg, vaddr_t va, pt_entry_t *nptep)
169{
170 return false;
171}
172
173static inline void
174pmap_md_vca_remove(struct vm_page_md *mdpg, vaddr_t va)
175{
176}
177
178static inline void
179pmap_md_vca_clean(struct vm_page_md *mdpg, vaddr_t va, int op)
180{
181}
182
183static inline size_t
184pmap_md_tlb_asid_max(void)
185{
186 return PMAP_TLB_NUM_PIDS - 1;
187}
188
189#endif /* __PMAP_PRIVATE */
190#endif /* _KERNEL */
191
192#include <uvm/pmap/pmap.h>
193
194#endif /* !_MODULE */
195
196#if defined(MODULAR) || defined(_MODULE)
197/*
198 * Define a compatible vm_page_md so that struct vm_page is the same size
199 * whether we are using modules or not.
200 */
201#ifndef __HAVE_VM_PAGE_MD
202#define __HAVE_VM_PAGE_MD
203
204struct vm_page_md {
205 uintptr_t mdpg_dummy[3];
206};
207__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3);
208
209#endif /* !__HAVE_VM_PAGE_MD */
210
211#endif /* MODULAR || _MODULE */
212
213#endif /* !_RISCV_PMAP_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/proc.h deleted-71
......@@ -1,71 +0,0 @@
1/* $NetBSD: proc.h,v 1.3 2015/03/31 06:47:47 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_PROC_H_
33#define _RISCV_PROC_H_
34
35#include <sys/param.h>
36#include <riscv/vmparam.h>
37
38struct lwp;
39
40/*
41 * Machine-dependent part of the lwp structure for RISCV
42 */
43struct trapframe;
44
45struct mdlwp {
46 struct trapframe *md_utf; /* trapframe from userspace */
47 struct trapframe *md_ktf; /* trapframe from userspace */
48 struct faultbuf *md_onfault; /* registers to store on fault */
49 register_t md_usp; /* for locore.S */
50 vaddr_t md_ss_addr; /* single step address for ptrace */
51 int md_ss_instr; /* single step instruction for ptrace */
52 volatile int md_astpending; /* AST pending on return to userland */
53#if 0
54#if USPACE > PAGE_SIZE
55 int md_upte[USPACE/4096]; /* ptes for mapping u page */
56#else
57 int md_dpte[USPACE/4096]; /* dummy ptes to keep the same */
58#endif
59#endif
60};
61
62struct mdproc {
63 /* syscall entry for this process */
64 void (*md_syscall)(struct trapframe *);
65};
66
67#ifdef _KERNEL
68#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */
69#endif /* _KERNEL */
70
71#endif /* _RISCV_PROC_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/profile.h deleted-91
......@@ -1,91 +0,0 @@
1/* $NetBSD: profile.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_PROFILE_H_
33#define _RISCV_PROFILE_H_
34
35#define _MCOUNT_DECL void _mcount
36
37/*
38 * Cannot implement mcount in C as GCC will trash the ip register when it
39 * pushes a trapframe. Pity we cannot insert assembly before the function
40 * prologue.
41 */
42
43#define MCOUNT_ASM_NAME "__mcount"
44#define PLTSYM
45
46#if 0
47#define MCOUNT \
48 __asm(".text"); \
49 __asm(".align 0"); \
50 __asm(".type " MCOUNT_ASM_NAME ",@function"); \
51 __asm(".global " MCOUNT_ASM_NAME); \
52 __asm(MCOUNT_ASM_NAME ":"); \
53 /* \
54 * Preserve registers that are trashed during mcount \
55 */ \
56 __asm("sub sp, sp, #80"); \
57 __asm("stp x29, x30, [sp, #64]"); \
58 __asm("add x29, sp, #64"); \
59 __asm("stp x0, x1, [x29, #0]"); \
60 __asm("stp x2, x3, [x29, #16]"); \
61 __asm("stp x4, x5, [x29, #32]"); \
62 __asm("stp x6, x7, [x29, #48]"); \
63 /* \
64 * find the return address for mcount, \
65 * and the return address for mcount's caller. \
66 * \
67 * frompcindex = pc pushed by call into self. \
68 */ \
69 __asm("mov x0, x19"); \
70 /* \
71 * selfpc = pc pushed by mcount call \
72 */ \
73 __asm("mov x1, x30"); \
74 /* \
75 * Call the real mcount code \
76 */ \
77 __asm("bl " ___STRING(_C_LABEL(_mcount))); \
78 /* \
79 * Restore registers that were trashed during mcount \
80 */ \
81 __asm("ldp x0, x1, [x29, #0]"); \
82 __asm("ldp x2, x3, [x29, #16]"); \
83 __asm("ldp x4, x5, [x29, #32]"); \
84 __asm("ldp x6, x7, [x29, #48]"); \
85 __asm("ldp x29, x30, [x29, #64]"); \
86 __asm("add sp, sp, #80"); \
87 __asm("ret"); \
88 __asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
89#endif
90
91#endif /* _RISCV_PROFILE_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/ptrace.h deleted-57
......@@ -1,57 +0,0 @@
1/* $NetBSD: ptrace.h,v 1.3 2019/06/18 21:18:12 kamil Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_PTRACE_H_
33#define _RISCV_PTRACE_H_
34
35/*
36 * RISCV-dependent ptrace definitions.
37 * Note that PT_STEP is _not_ supported.
38 */
39#define PT_GETREGS (PT_FIRSTMACH + 0)
40#define PT_SETREGS (PT_FIRSTMACH + 1)
41#define PT_GETFPREGS (PT_FIRSTMACH + 2)
42#define PT_SETFPREGS (PT_FIRSTMACH + 3)
43
44#define PT_MACHDEP_STRINGS \
45 "PT_GETREGS", \
46 "PT_SETREGS", \
47 "PT_GETFPREGS", \
48 "PT_SETFPREGS"
49
50#include <machine/reg.h>
51#define PTRACE_REG_PC(r) (r)->r_pc
52#define PTRACE_REG_FP(r) (r)->r_reg[7]
53#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v)
54#define PTRACE_REG_SP(r) (r)->r_reg[1]
55#define PTRACE_REG_INTRV(r) (r)->r_reg[9]
56
57#endif /* _RISCV_PTRACE_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/reg.h deleted-125
......@@ -1,125 +0,0 @@
1/* $NetBSD: reg.h,v 1.10 2022/12/13 22:25:08 skrll Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_REG_H_
33#define _RISCV_REG_H_
34
35// x0 = 0
36// x1 = ra (return address) Caller
37// x2 = sp (stack pointer) Callee
38// x3 = gp (global pointer)
39// x4 = tp (thread pointer)
40// x5 - x7 = t0 - t2 (temporary) Caller
41// x8 = s0/fp (saved register / frame pointer) Callee
42// x9 = s1 (saved register) Callee
43// x10 - x11 = a0 - a1 (arguments/return values) Caller
44// x12 - x17 = a2 - a7 (arguments) Caller
45// x18 - x27 = s2 - s11 (saved registers) Callee
46// x28 - x31 = t3 - t6 (temporaries) Caller
47
48struct reg { // synced with register_t in <riscv/types.h>
49#ifdef _LP64
50 __uint64_t r_reg[31]; /* x0 is always 0 */
51 __uint64_t r_pc;
52#else
53 __uint32_t r_reg[31]; /* x0 is always 0 */
54 __uint32_t r_pc;
55#endif
56};
57
58#ifdef _LP64
59struct reg32 { // synced with register_t in <riscv/types.h>
60 __uint32_t r_reg[31]; /* x0 is always 0 */
61 __uint32_t r_pc;
62};
63#endif
64
65#define _XREG(n) ((n) - 1)
66#define _X_RA _XREG(1)
67#define _X_SP _XREG(2)
68#define _X_GP _XREG(3)
69#define _X_TP _XREG(4)
70#define _X_T0 _XREG(5)
71#define _X_T1 _XREG(6)
72#define _X_T2 _XREG(7)
73#define _X_S0 _XREG(8)
74#define _X_S1 _XREG(9)
75#define _X_A0 _XREG(10)
76#define _X_A1 _XREG(11)
77#define _X_A2 _XREG(12)
78#define _X_A3 _XREG(13)
79#define _X_A4 _XREG(14)
80#define _X_A5 _XREG(15)
81#define _X_A6 _XREG(16)
82#define _X_A7 _XREG(17)
83#define _X_S2 _XREG(18)
84#define _X_S3 _XREG(19)
85#define _X_S4 _XREG(20)
86#define _X_S5 _XREG(21)
87#define _X_S6 _XREG(22)
88#define _X_S7 _XREG(23)
89#define _X_S8 _XREG(24)
90#define _X_S9 _XREG(25)
91#define _X_S10 _XREG(26)
92#define _X_S11 _XREG(27)
93#define _X_T3 _XREG(28)
94#define _X_T4 _XREG(29)
95#define _X_T5 _XREG(30)
96#define _X_T6 _XREG(31)
97
98// f0 - f7 = ft0 - ft7 (FP temporaries) Caller
99// following layout is similar to integer registers above
100// f8 - f9 = fs0 - fs1 (FP saved registers) Callee
101// f10 - f11 = fa0 - fa1 (FP arguments/return values) Caller
102// f12 - f17 = fa2 - fa7 (FP arguments) Caller
103// f18 - f27 = fs2 - fa11 (FP saved registers) Callee
104// f28 - f31 = ft8 - ft11 (FP temporaries) Caller
105
106/*
107 * This fragment is common to <riscv/mcontext.h> and <riscv/reg.h>
108 */
109#ifndef _BSD_FPREG_T_
110union __fpreg {
111 __uint64_t u_u64;
112 double u_d;
113};
114#define _BSD_FPREG_T_ union __fpreg
115#endif
116
117/*
118 * 32 double precision floating point, 1 CSR
119 */
120struct fpreg {
121 _BSD_FPREG_T_ r_fpreg[33];
122};
123#define r_fcsr r_fpreg[32].u_u64
124
125#endif /* _RISCV_REG_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/rwlock.h deleted-1
......@@ -1 +0,0 @@
1/* $NetBSD: rwlock.h,v 1.2 2019/11/29 20:04:53 riastradh Exp $ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/setjmp.h deleted-70
......@@ -1,70 +0,0 @@
1/* $NetBSD: setjmp.h,v 1.2 2015/03/27 06:57:21 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /* magic + 16 reg + 1 fcsr + 12 fp + 4 sigmask + 8 spare */
33#define _JBLEN (_JB_SIGMASK + 4 + 8)
34#define _JB_MAGIC 0
35#define _JB_RA 1
36#define _JB_SP 2
37#define _JB_GP 3
38#define _JB_TP 4
39#define _JB_S0 5
40#define _JB_S1 6
41#define _JB_S2 7
42#define _JB_S3 8
43#define _JB_S4 9
44#define _JB_S5 10
45#define _JB_S6 11
46#define _JB_S7 12
47#define _JB_S8 13
48#define _JB_S9 14
49#define _JB_S10 15
50#define _JB_S11 16
51#define _JB_FCSR 17
52
53#define _JB_FS0 18
54#define _JB_FS1 (_JB_FS0 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
55#define _JB_FS2 (_JB_FS1 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
56#define _JB_FS3 (_JB_FS2 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
57#define _JB_FS4 (_JB_FS3 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
58#define _JB_FS5 (_JB_FS4 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
59#define _JB_FS6 (_JB_FS5 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
60#define _JB_FS7 (_JB_FS6 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
61#define _JB_FS8 (_JB_FS7 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
62#define _JB_FS9 (_JB_FS8 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
63#define _JB_FS10 (_JB_FS9 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
64#define _JB_FS11 (_JB_FS10 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
65
66#define _JB_SIGMASK (_JB_FS11 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
67
68#ifndef _BSD_JBSLOT_T_
69#define _BSD_JBSLOT_T_ long long
70#endif
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/signal.h deleted-39
......@@ -1,39 +0,0 @@
1/* $NetBSD: signal.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_SIGNAL_H_
33#define _RISCV_SIGNAL_H_
34
35#ifndef _LOCORE
36typedef __SIG_ATOMIC_TYPE__ sig_atomic_t;
37#endif
38
39#endif /* _RISCV_SIGNAL_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/sysarch.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: sysarch.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3/* nothing */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/sysreg.h deleted-337
......@@ -1,337 +0,0 @@
1/* $NetBSD: sysreg.h,v 1.28 2022/12/03 11:09:59 skrll Exp $ */
2
3/*
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_SYSREG_H_
33#define _RISCV_SYSREG_H_
34
35#ifndef _KERNEL
36#include <sys/param.h>
37#endif
38
39#include <riscv/reg.h>
40
41#define FCSR_FMASK 0 // no exception bits
42#define FCSR_FRM __BITS(7, 5)
43#define FCSR_FRM_RNE 0b000 // Round Nearest, ties to Even
44#define FCSR_FRM_RTZ 0b001 // Round Towards Zero
45#define FCSR_FRM_RDN 0b010 // Round DowN (-infinity)
46#define FCSR_FRM_RUP 0b011 // Round UP (+infinity)
47#define FCSR_FRM_RMM 0b100 // Round to nearest, ties to Max Magnitude
48#define FCSR_FRM_DYN 0b111 // Dynamic rounding
49#define FCSR_FFLAGS __BITS(4, 0) // Sticky bits
50#define FCSR_NV __BIT(4) // iNValid operation
51#define FCSR_DZ __BIT(3) // Divide by Zero
52#define FCSR_OF __BIT(2) // OverFlow
53#define FCSR_UF __BIT(1) // UnderFlow
54#define FCSR_NX __BIT(0) // iNeXact
55
56static inline uint32_t
57riscvreg_fcsr_read(void)
58{
59 uint32_t __fcsr;
60 __asm("frcsr %0" : "=r"(__fcsr));
61 return __fcsr;
62}
63
64
65static inline uint32_t
66riscvreg_fcsr_write(uint32_t __new)
67{
68 uint32_t __old;
69 __asm("fscsr %0, %1" : "=r"(__old) : "r"(__new));
70 return __old;
71}
72
73static inline uint32_t
74riscvreg_fcsr_read_fflags(void)
75{
76 uint32_t __old;
77 __asm("frflags %0" : "=r"(__old));
78 return __SHIFTOUT(__old, FCSR_FFLAGS);
79}
80
81static inline uint32_t
82riscvreg_fcsr_write_fflags(uint32_t __new)
83{
84 uint32_t __old;
85 __new = __SHIFTIN(__new, FCSR_FFLAGS);
86 __asm("fsflags %0, %1" : "=r"(__old) : "r"(__new));
87 return __SHIFTOUT(__old, FCSR_FFLAGS);
88}
89
90static inline uint32_t
91riscvreg_fcsr_read_frm(void)
92{
93 uint32_t __old;
94 __asm("frrm\t%0" : "=r"(__old));
95 return __SHIFTOUT(__old, FCSR_FRM);
96}
97
98static inline uint32_t
99riscvreg_fcsr_write_frm(uint32_t __new)
100{
101 uint32_t __old;
102 __new = __SHIFTIN(__new, FCSR_FRM);
103 __asm __volatile("fsrm\t%0, %1" : "=r"(__old) : "r"(__new));
104 return __SHIFTOUT(__old, FCSR_FRM);
105}
106
107
108#define RISCVREG_READ_INLINE(regname) \
109static inline uintptr_t \
110csr_##regname##_read(void) \
111{ \
112 uintptr_t __rv; \
113 asm volatile("csrr %0, " #regname : "=r"(__rv) :: "memory"); \
114 return __rv; \
115}
116
117#define RISCVREG_WRITE_INLINE(regname) \
118static inline void \
119csr_##regname##_write(uintptr_t __val) \
120{ \
121 asm volatile("csrw " #regname ", %0" :: "r"(__val) : "memory"); \
122}
123
124#define RISCVREG_SET_INLINE(regname) \
125static inline void \
126csr_##regname##_set(uintptr_t __mask) \
127{ \
128 if (__builtin_constant_p(__mask) && __mask < 0x20) { \
129 asm volatile("csrsi " #regname ", %0" :: "i"(__mask) : \
130 "memory"); \
131 } else { \
132 asm volatile("csrs " #regname ", %0" :: "r"(__mask) : \
133 "memory"); \
134 } \
135}
136
137#define RISCVREG_CLEAR_INLINE(regname) \
138static inline void \
139csr_##regname##_clear(uintptr_t __mask) \
140{ \
141 if (__builtin_constant_p(__mask) && __mask < 0x20) { \
142 asm volatile("csrci " #regname ", %0" :: "i"(__mask) : \
143 "memory"); \
144 } else { \
145 asm volatile("csrc " #regname ", %0" :: "r"(__mask) : \
146 "memory"); \
147 } \
148}
149
150#define RISCVREG_READ_WRITE_INLINE(regname) \
151RISCVREG_READ_INLINE(regname) \
152RISCVREG_WRITE_INLINE(regname)
153#define RISCVREG_SET_CLEAR_INLINE(regname) \
154RISCVREG_SET_INLINE(regname) \
155RISCVREG_CLEAR_INLINE(regname)
156#define RISCVREG_READ_SET_CLEAR_INLINE(regname) \
157RISCVREG_READ_INLINE(regname) \
158RISCVREG_SET_CLEAR_INLINE(regname)
159#define RISCVREG_READ_WRITE_SET_CLEAR_INLINE(regname) \
160RISCVREG_READ_WRITE_INLINE(regname) \
161RISCVREG_SET_CLEAR_INLINE(regname)
162
163/* Supervisor Status Register */
164RISCVREG_READ_SET_CLEAR_INLINE(sstatus) // supervisor status register
165#ifdef _LP64
166#define SR_WPRI __BITS(62, 34) | __BITS(31, 20) | \
167 __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \
168 __BIT(0)
169#define SR_SD __BIT(63) // any of FS or VS or XS dirty
170 /* Bits 62-34 are WPRI */
171#define SR_UXL __BITS(33, 32) // U-mode XLEN
172#define SR_UXL_32 1 // XLEN == 32
173#define SR_UXL_64 2 // XLEN == 64
174#define SR_UXL_128 3 // XLEN == 128
175 /* Bits 31-20 are WPRI*/
176#else
177#define SR_WPRI __BITS(30, 20) | \
178 __BIT(17) | __BITS(12, 11) | __BIT(7) | __BITS(4, 2) | \
179 __BIT(0)
180#define SR_SD __BIT(31) // any of FS or VS or XS dirty
181 /* Bits 30-20 are WPRI*/
182#endif /* _LP64 */
183
184/* Both RV32 and RV64 have the bottom 20 bits shared */
185#define SR_MXR __BIT(19) // Make eXecutable Readable
186#define SR_SUM __BIT(18) // permit Supervisor User Memory access
187 /* Bit 17 is WPRI */
188#define SR_XS __BITS(16, 15) // Vector extension state
189#define SR_XS_OFF 0 // All off
190#define SR_XS_SOME_ON 1 // None dirty or clean, some on
191#define SR_XS_SOME_CLEAN 2 // None dirty, some clean
192#define SR_XS_SOME_DIRTY 3 // Some dirty
193#define SR_FS __BITS(14, 13) // Floating-point unit state
194#define SR_FS_OFF 0 // Off
195#define SR_FS_INITIAL 1 // Initial
196#define SR_FS_CLEAN 2 // Clean
197#define SR_FS_DIRTY 3 // Dirty
198 /* Bits 12-11 are WPRI */
199#define SR_VS __BITS(10, 9) // User-mode extention state
200#define SR_VS_OFF SR_FS_OFF // Off
201#define SR_VS_INITIAL SR_FS_INITIAL // Initial
202#define SR_VS_CLEAN SR_FS_CLEAN // Clean
203#define SR_VS_DIRTY SR_FS_DIRTY // Dirty
204#define SR_SPP __BIT(8) // Priv level before supervisor mode
205 /* Bit 7 is WPRI */
206#define SR_UBE __BIT(6) // User-mode endianness
207#define SR_SPIE __BIT(5) // S-Mode interrupts enabled before trap
208 /* Bits 4-2 are WPRI */
209#define SR_SIE __BIT(1) // Supervisor mode interrupt enable
210 /* Bit 0 is WPRI */
211
212/* Supervisor interrupt registers */
213/* ... interrupt pending register (sip) */
214RISCVREG_READ_SET_CLEAR_INLINE(sip) // supervisor interrupt pending
215 /* Bit (XLEN-1) - 10 is WIRI */
216#define SIP_SEIP __BIT(9) // S-mode interrupt pending
217 /* Bit 8-6 is WIRI */
218#define SIP_STIP __BIT(5) // S-mode timer interrupt pending
219 /* Bit 4-2 is WIRI */
220#define SIP_SSIP __BIT(1) // S-mode software interrupt pending
221 /* Bit 0 is WIRI */
222
223/* ... interrupt-enable register (sie) */
224RISCVREG_READ_SET_CLEAR_INLINE(sie) // supervisor interrupt enable
225 /* Bit (XLEN-1) - 10 is WIRI */
226#define SIE_SEIE __BIT(9) // S-mode interrupt enable
227 /* Bit 8-6 is WIRI */
228#define SIE_STIE __BIT(5) // S-mode timer interrupt enable
229 /* Bit 4-2 is WIRI */
230#define SIE_SSIE __BIT(1) // S-mode software interrupt enable
231 /* Bit 0 is WIRI */
232
233/* Mask for all interrupts */
234#define SIE_IM (SIE_SEI |SIE_STIE | SIE_SSIE)
235
236#ifdef _LP64
237#define SR_USER64 (SR_SPIE | SR_UXL_64) // 64-bit U-mode sstatus
238#define SR_USER32 (SR_SPIE | SR_UXL_32) // 32-bit U-mode sstatus
239#else
240#define SR_USER (SR_SPIE) // U-mode sstatus
241#endif
242
243// Cause register
244#define CAUSE_INTERRUPT_P(cause) ((cause) & __BIT(XLEN - 1))
245#define CAUSE_CODE(cause) ((cause) & __BITS(XLEN - 2, 0))
246
247// Cause register - exceptions
248#define CAUSE_FETCH_MISALIGNED 0
249#define CAUSE_FETCH_ACCESS 1
250#define CAUSE_ILLEGAL_INSTRUCTION 2
251#define CAUSE_BREAKPOINT 3
252#define CAUSE_LOAD_MISALIGNED 4
253#define CAUSE_LOAD_ACCESS 5
254#define CAUSE_STORE_MISALIGNED 6
255#define CAUSE_STORE_ACCESS 7
256#define CAUSE_USER_ECALL 8
257#define CAUSE_SYSCALL CAUSE_USER_ECALL /* convenience alias */
258#define CAUSE_SUPERVISOR_ECALL 9
259/* 10 is reserved */
260#define CAUSE_MACHINE_ECALL 11
261#define CAUSE_FETCH_PAGE_FAULT 12
262#define CAUSE_LOAD_PAGE_FAULT 13
263/* 14 is Reserved */
264#define CAUSE_STORE_PAGE_FAULT 15
265/* >= 16 is reserved/custom */
266
267// Cause register - interrupts
268#define IRQ_SUPERVISOR_SOFTWARE 1
269#define IRQ_MACHINE_SOFTWARE 3
270#define IRQ_SUPERVISOR_TIMER 5
271#define IRQ_MACHINE_TIMER 7
272#define IRQ_SUPERVISOR_EXTERNAL 9
273#define IRQ_MACHINE_EXTERNAL 11
274
275RISCVREG_READ_INLINE(time)
276#ifdef _LP64
277RISCVREG_READ_INLINE(cycle)
278#else /* !_LP64 */
279static inline uint64_t
280csr_cycle_read(void)
281{
282 uint32_t __hi0, __hi1, __lo0;
283 do {
284 __asm __volatile(
285 "csrr\t%[__hi0], cycleh"
286 "\n\t" "csrr\t%[__lo0], cycle"
287 "\n\t" "csrr\t%[__hi1], cycleh"
288 : [__hi0] "=r"(__hi0),
289 [__lo0] "=r"(__lo0),
290 [__hi1] "=r"(__hi1));
291 } while (__hi0 != __hi1);
292 return
293 __SHIFTIN(__hi0, __BITS(63, 32)) |
294 __SHIFTIN(__lo0, __BITS(31, 0));
295}
296#endif /* !_LP64 */
297
298#ifdef _LP64
299#define SATP_MODE __BITS(63, 60) // Translation mode
300#define SATP_MODE_BARE 0 // No translation or protection
301 /* modes 1-7 reserved for standard use */
302#define SATP_MODE_SV39 8 // Page-based 39-bit virt addr
303#define SATP_MODE_SV48 9 // Page-based 48-bit virt addr
304#define SATP_MODE_SV57 10 // Page-based 57-bit virt addr
305#define SATP_MODE_SV64 11 // Page-based 64-bit virt addr
306 /* modes 12-13 reserved for standard use */
307 /* modes 14-15 designated for custom use */
308#define SATP_ASID __BITS(59, 44) // Address Space Identifier
309#define SATP_PPN __BITS(43, 0) // Physical Page Number
310#else
311#define SATP_MODE __BIT(31) // Translation mode
312#define SATP_MODE_BARE 0 // No translation or protection
313#define SATP_MODE_SV32 1 // Page-based 32-bit virt addr
314#define SATP_ASID __BITS(30, 22) // Address Space Identifier
315#define SATP_PPN __BITS(21, 0) // Physical Page Number
316#endif
317
318RISCVREG_READ_WRITE_INLINE(satp)
319
320/* Fake "ASID" CSR (a field of SATP register) functions */
321static inline uint32_t
322csr_asid_read(void)
323{
324 uintptr_t satp = csr_satp_read();
325 return __SHIFTOUT(satp, SATP_ASID);
326}
327
328static inline void
329csr_asid_write(uint32_t asid)
330{
331 uintptr_t satp = csr_satp_read();
332 satp &= ~SATP_ASID;
333 satp |= __SHIFTIN(asid, SATP_ASID);
334 csr_satp_write(satp);
335}
336
337#endif /* _RISCV_SYSREG_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/types.h deleted-116
......@@ -1,116 +0,0 @@
1/* $NetBSD: types.h,v 1.15 2022/11/08 13:34:17 simonb Exp $ */
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_TYPES_H_
33#define _RISCV_TYPES_H_
34
35#include <sys/cdefs.h>
36#include <sys/featuretest.h>
37#include <riscv/int_types.h>
38
39#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE)
40
41/* XLEN is the native base integer ISA width */
42#define XLEN (sizeof(long) * NBBY)
43
44typedef __uint64_t paddr_t;
45typedef __uint64_t psize_t;
46#define PRIxPADDR PRIx64
47#define PRIxPSIZE PRIx64
48#define PRIuPSIZE PRIu64
49
50typedef __UINTPTR_TYPE__ vaddr_t;
51typedef __UINTPTR_TYPE__ vsize_t;
52#define PRIxVADDR PRIxPTR
53#define PRIxVSIZE PRIxPTR
54#define PRIuVSIZE PRIuPTR
55
56#ifdef _LP64 // match <riscv/reg.h>
57#define PRIxREGISTER PRIx64
58typedef __int64_t register_t;
59typedef __uint64_t uregister_t;
60#else
61#define PRIxREGISTER PRIx32
62typedef __int32_t register_t;
63typedef __uint32_t uregister_t;
64#endif
65typedef signed int register32_t;
66typedef unsigned int uregister32_t;
67#define PRIxREGISTER32 "x"
68
69typedef unsigned int tlb_asid_t;
70#endif
71
72#if defined(_KERNEL)
73typedef struct label_t { /* Used by setjmp & longjmp */
74 register_t lb_reg[16]; /* */
75 __uint32_t lb_sr;
76} label_t;
77#endif
78
79typedef unsigned int __cpu_simple_lock_nv_t;
80#ifdef _LP64
81typedef __int64_t __register_t;
82#else
83typedef __int32_t __register_t;
84#endif
85
86#define __SIMPLELOCK_LOCKED 1
87#define __SIMPLELOCK_UNLOCKED 0
88
89#define __HAVE_COMMON___TLS_GET_ADDR
90#define __HAVE_COMPAT_NETBSD32
91#define __HAVE_CPU_COUNTER
92#define __HAVE_CPU_DATA_FIRST
93#define __HAVE_FAST_SOFTINTS
94#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS
95#define __HAVE_NEW_STYLE_BUS_H
96#define __HAVE_SYSCALL_INTERN
97#define __HAVE_TLS_VARIANT_I
98/* XXX temporary */
99#define __HAVE_UNLOCKED_PMAP
100#define __HAVE___LWP_GETPRIVATE_FAST
101
102#ifdef __LP64
103#define __HAVE_ATOMIC64_OPS
104#define __HAVE_CPU_UAREA_ROUTINES
105#endif
106
107//#if defined(_KERNEL)
108//#define __HAVE_RAS
109//#endif
110
111#if defined(_KERNEL) || defined(_KMEMUSER)
112#define PCU_FPU 0
113#define PCU_UNIT_COUNT 1
114#endif
115
116#endif /* _RISCV_TYPES_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/vmparam.h deleted-203
......@@ -1,203 +0,0 @@
1/* $NetBSD: vmparam.h,v 1.13 2022/10/16 06:14:53 skrll Exp $ */
2
3/*-
4 * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry, and Nick Hudson.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _RISCV_VMPARAM_H_
33#define _RISCV_VMPARAM_H_
34
35#include <riscv/param.h>
36
37#ifdef _KERNEL_OPT
38#include "opt_multiprocessor.h"
39#endif
40
41/*
42 * Machine dependent VM constants for RISCV.
43 */
44
45/*
46 * We use a 4K page on both RV64 and RV32 systems.
47 * Override PAGE_* definitions to compile-time constants.
48 */
49#define PAGE_SHIFT PGSHIFT
50#define PAGE_SIZE (1 << PAGE_SHIFT)
51#define PAGE_MASK (PAGE_SIZE - 1)
52
53/*
54 * USRSTACK is the top (end) of the user stack.
55 *
56 * USRSTACK needs to start a page below the maxuser address so that a memory
57 * access with a maximum displacement (0x7ff) won't cross into the kernel's
58 * address space. We use PAGE_SIZE instead of 0x800 since these need to be
59 * page-aligned.
60 */
61#define USRSTACK (VM_MAXUSER_ADDRESS-PAGE_SIZE) /* Start of user stack */
62#define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS32-PAGE_SIZE)
63
64/*
65 * Virtual memory related constants, all in bytes
66 */
67#ifndef MAXTSIZ
68#define MAXTSIZ (128*1024*1024) /* max text size */
69#endif
70#ifndef DFLDSIZ
71#define DFLDSIZ (256*1024*1024) /* initial data size limit */
72#endif
73#ifndef MAXDSIZ
74#define MAXDSIZ (1536*1024*1024) /* max data size */
75#endif
76#ifndef DFLSSIZ
77#define DFLSSIZ (4*1024*1024) /* initial stack size limit */
78#endif
79#ifndef MAXSSIZ
80#define MAXSSIZ (120*1024*1024) /* max stack size */
81#endif
82
83/*
84 * Virtual memory related constants, all in bytes
85 */
86#ifndef DFLDSIZ32
87#define DFLDSIZ32 DFLDSIZ /* initial data size limit */
88#endif
89#ifndef MAXDSIZ32
90#define MAXDSIZ32 MAXDSIZ /* max data size */
91#endif
92#ifndef DFLSSIZ32
93#define DFLSSIZ32 DFLTSIZ /* initial stack size limit */
94#endif
95#ifndef MAXSSIZ32
96#define MAXSSIZ32 MAXSSIZ /* max stack size */
97#endif
98
99/*
100 * PTEs for mapping user space into the kernel for phyio operations.
101 * The default PTE number is enough to cover 8 disks * MAXBSIZE.
102 */
103#ifndef USRIOSIZE
104#define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8)
105#endif
106
107/*
108 * User/kernel map constants.
109 */
110#define VM_MIN_ADDRESS ((vaddr_t)0x00000000)
111#ifdef _LP64 /* Sv39 / Sv48 / Sv57 */
112/*
113 * kernel virtual space layout:
114 * 0xffff_ffc0_0000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss)
115 * (0xffff_ffc0_4000_0000 +1GiB) KERNEL VM start of KVA
116 * (0xffff_ffd0_0000_0000 64GiB) reserved
117 * 0xffff_ffe0_0000_0000 - 128GiB direct mapping
118 */
119#define VM_MAXUSER_ADDRESS ((vaddr_t)0x0000004000000000 - 16 * PAGE_SIZE)
120#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffc000000000)
121#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000)
122
123#else /* Sv32 */
124#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */
125#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */
126#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xffffffffc0000000 */
127
128#endif
129#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS
130#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */
131#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE)
132#define VM_KERNEL_DTB_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
133#define VM_KERNEL_IO_BASE (VM_KERNEL_DTB_BASE + VM_KERNEL_DTB_SIZE)
134#define VM_KERNEL_IO_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
135
136#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE + VM_KERNEL_IO_SIZE)
137
138#define VM_KERNEL_VM_BASE (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_RESERVED)
139#define VM_KERNEL_VM_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_VM_BASE)
140
141#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
142#define VM_MAXUSER_ADDRESS32 ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */
143
144#ifdef _LP64
145/*
146 * Since we have the address space, we map all of physical memory (RAM)
147 * using gigapages on SV39, terapages on SV48 and petapages on SV57.
148 */
149#define RISCV_DIRECTMAP_MASK ((vaddr_t) 0xffffffe000000000L)
150#define RISCV_DIRECTMAP_SIZE (-RISCV_DIRECTMAP_MASK - PAGE_SIZE) /* 128GiB */
151#define RISCV_DIRECTMAP_START RISCV_DIRECTMAP_MASK
152#define RISCV_DIRECTMAP_END (RISCV_DIRECTMAP_START + RISCV_DIRECTMAP_SIZE)
153#define RISCV_KVA_P(va) (((vaddr_t) (va) & RISCV_DIRECTMAP_MASK) != 0)
154#define RISCV_PA_TO_KVA(pa) ((vaddr_t) ((pa) | RISCV_DIRECTMAP_START))
155#define RISCV_KVA_TO_PA(va) ((paddr_t) ((va) & ~RISCV_DIRECTMAP_MASK))
156#endif
157
158/*
159 * The address to which unspecified mapping requests default
160 */
161#define __USE_TOPDOWN_VM
162
163#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \
164 trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size)
165#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \
166 round_page((vaddr_t)(da) + (vsize_t)maxdmap)
167
168#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \
169 trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size)
170#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \
171 round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32)
172
173/* virtual sizes (bytes) for various kernel submaps */
174#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE)
175
176/* VM_PHYSSEG_MAX defined by platform-dependent code. */
177#ifndef VM_PHYSSEG_MAX
178#define VM_PHYSSEG_MAX 16
179#endif
180#if VM_PHYSSEG_MAX == 1
181#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST
182#else
183#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH
184#endif
185#define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */
186
187#ifndef VM_NFREELIST
188#define VM_NFREELIST 2 /* 2 distinct memory segments */
189#define VM_FREELIST_DEFAULT 0
190#define VM_FREELIST_DIRECTMAP 1
191#endif
192
193#ifdef _KERNEL
194#define UVM_KM_VMFREELIST riscv_poolpage_vmfreelist
195extern int riscv_poolpage_vmfreelist;
196
197#ifdef _LP64
198void * cpu_uarea_alloc(bool);
199bool cpu_uarea_free(void *);
200#endif
201#endif
202
203#endif /* ! _RISCV_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/wchar_limits.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: wchar_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
2
3#include <sys/common_wchar_limits.h>
\ No newline at end of file
lib/libc/include/generic-netbsd/soundcard.h created+664
......@@ -0,0 +1,664 @@
1/* $NetBSD: soundcard.h,v 1.34 2021/05/09 11:28:25 nia Exp $ */
2
3/*-
4 * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson and Nia Alarie.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*
33 * WARNING! WARNING!
34 * This is an Open Sound System compatibility layer.
35 * Use the Native NetBSD API in <sys/audioio.h> for developing new code,
36 * and this only for compiling programs written for other operating systems.
37 */
38
39#ifndef _SOUNDCARD_H_
40#define _SOUNDCARD_H_
41
42#ifndef SOUND_VERSION
43#define SOUND_VERSION 0x030001
44#endif
45
46#define SNDCTL_DSP_RESET _IO ('P', 0)
47#define SNDCTL_DSP_SYNC _IO ('P', 1)
48#define SNDCTL_DSP_SPEED _IOWR('P', 2, int)
49#define SOUND_PCM_READ_RATE _IOR ('P', 2, int)
50#define SNDCTL_DSP_STEREO _IOWR('P', 3, int)
51#define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int)
52#define SNDCTL_DSP_SETFMT _IOWR('P', 5, int)
53#define AFMT_QUERY 0x00000000
54#define AFMT_MU_LAW 0x00000001
55#define AFMT_A_LAW 0x00000002
56#define AFMT_IMA_ADPCM 0x00000004
57#define AFMT_U8 0x00000008
58#define AFMT_S16_LE 0x00000010
59#define AFMT_S16_BE 0x00000020
60#define AFMT_S8 0x00000040
61#define AFMT_U16_LE 0x00000080
62#define AFMT_U16_BE 0x00000100
63#define AFMT_MPEG 0x00000200 /* Not supported */
64#define AFMT_AC3 0x00000400
65#define AFMT_S24_LE 0x00000800 /* Not supported */
66#define AFMT_S24_BE 0x00001000 /* Not supported */
67#define AFMT_S32_LE 0x00002000
68#define AFMT_S32_BE 0x00004000
69#define AFMT_FLOAT 0x00010000 /* Not supported */
70#define AFMT_SPDIF_RAW 0x00020000 /* Not supported */
71#define AFMT_S24_PACKED 0x00040000 /* Not supported */
72#define AFMT_VORBIS 0x00080000 /* Not supported */
73#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
74#define SOUND_PCM_READ_BITS _IOR ('P', 5, int)
75#define SNDCTL_DSP_CHANNELS _IOWR('P', 6, int)
76#define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS
77#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int)
78#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int)
79#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int)
80#define SNDCTL_DSP_POST _IO ('P', 8)
81#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int)
82#define SNDCTL_DSP_SETFRAGMENT _IOWR('P', 10, int)
83#define SNDCTL_DSP_GETFMTS _IOR ('P', 11, int)
84#define SNDCTL_DSP_GETOSPACE _IOR ('P',12, struct audio_buf_info)
85#define SNDCTL_DSP_GETISPACE _IOR ('P',13, struct audio_buf_info)
86#define SNDCTL_DSP_NONBLOCK _IO ('P',14)
87#define SNDCTL_DSP_GETCAPS _IOR ('P',15, int)
88/* PCM_CAP_* were known as DSP_CAP_ before OSS 4.0 */
89# define DSP_CAP_REVISION PCM_CAP_REVISION
90# define DSP_CAP_DUPLEX PCM_CAP_DUPLEX
91# define DSP_CAP_REALTIME PCM_CAP_REALTIME
92# define DSP_CAP_BATCH PCM_CAP_BATCH
93# define DSP_CAP_COPROC PCM_CAP_COPROC
94# define DSP_CAP_TRIGGER PCM_CAP_TRIGGER
95# define DSP_CAP_MMAP PCM_CAP_MMAP
96# define DSP_CAP_INPUT PCM_CAP_INPUT
97# define DSP_CAP_OUTPUT PCM_CAP_OUTPUT
98# define DSP_CAP_MODEM PCM_CAP_MODEM
99# define DSP_CAP_HIDDEN PCM_CAP_HIDDEN
100# define DSP_CAP_VIRTUAL PCM_CAP_VIRTUAL
101# define DSP_CAP_ANALOGOUT PCM_CAP_ANALOGOUT
102# define DSP_CAP_ANALOGIN PCM_CAP_ANALOGIN
103# define DSP_CAP_DIGITALOUT PCM_CAP_DIGITALOUT
104# define DSP_CAP_DIGITALIN PCM_CAP_DIGITALIN
105# define DSP_CAP_ADMASK PCM_CAP_ADMASK
106# define DSP_CAP_FREERATE PCM_CAP_FREERATE
107# define DSP_CAP_MULTI PCM_CAP_MULTI
108# define DSP_CAP_BIND PCM_CAP_BIND
109# define DSP_CAP_SHADOW PCM_CAP_SHADOW
110# define PCM_CAP_REVISION 0x000000ff /* Unused in NetBSD */
111# define PCM_CAP_DUPLEX 0x00000100 /* Full duplex */
112# define PCM_CAP_REALTIME 0x00000200 /* Unused in NetBSD */
113# define PCM_CAP_BATCH 0x00000400 /* Unused in NetBSD */
114# define PCM_CAP_COPROC 0x00000800 /* Unused in NetBSD */
115# define PCM_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
116# define PCM_CAP_MMAP 0x00002000 /* Supports mmap() */
117# define PCM_CAP_INPUT 0x00004000 /* Recording device */
118# define PCM_CAP_OUTPUT 0x00008000 /* Playback device */
119# define PCM_CAP_MODEM 0x00010000 /* Unused in NetBSD */
120# define PCM_CAP_HIDDEN 0x00020000 /* Unused in NetBSD */
121# define PCM_CAP_VIRTUAL 0x00040000 /* Unused in NetBSD */
122# define PCM_CAP_MULTI 0x00080000 /* Simultaneous open() */
123# define PCM_CAP_ANALOGOUT 0x00100000 /* Unused in NetBSD */
124# define PCM_CAP_ANALOGIN 0x00200000 /* Unused in NetBSD */
125# define PCM_CAP_DIGITALOUT 0x00400000 /* Unused in NetBSD */
126# define PCM_CAP_DIGITALIN 0x00800000 /* Unused in NetBSD */
127# define PCM_CAP_ADMASK 0x00f00000 /* Unused in NetBSD */
128# define PCM_CAP_SPECIAL 0x01000000 /* Unused in NetBSD */
129# define PCM_CAP_FREERATE 0x10000000 /* Freely set rate */
130# define PCM_CAP_SHADOW 0x40000000 /* Unused in NetBSD */
131# define PCM_CAP_BIND 0x80000000 /* Unused in NetBSD */
132# define DSP_CH_ANY 0x00000000 /* No preferred mode */
133# define DSP_CH_MONO 0x02000000
134# define DSP_CH_STEREO 0x04000000
135# define DSP_CH_MULTI 0x06000000
136# define DSP_CH_MASK 0x06000000
137#define SNDCTL_DSP_GETTRIGGER _IOR ('P', 16, int)
138#define SNDCTL_DSP_SETTRIGGER _IOW ('P', 16, int)
139# define PCM_ENABLE_INPUT 0x00000001
140# define PCM_ENABLE_OUTPUT 0x00000002
141#define SNDCTL_DSP_GETIPTR _IOR ('P', 17, struct count_info)
142#define SNDCTL_DSP_GETOPTR _IOR ('P', 18, struct count_info)
143#define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, struct buffmem_desc)
144#define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, struct buffmem_desc)
145#define SNDCTL_DSP_SETSYNCRO _IO ('P', 21)
146#define SNDCTL_DSP_SETDUPLEX _IO ('P', 22)
147#define SNDCTL_DSP_PROFILE _IOW ('P', 23, int)
148#define SNDCTL_DSP_GETODELAY _IOR ('P', 23, int)
149#define APF_NORMAL 0
150#define APF_NETWORK 1
151#define APF_CPUINTENS 2
152
153/* Need native 16 bit format which depends on byte order */
154#include <machine/endian_machdep.h>
155#if _BYTE_ORDER == _LITTLE_ENDIAN
156#define AFMT_U16_NE AFMT_U16_LE
157#define AFMT_U16_OE AFMT_U16_BE
158#define AFMT_S16_NE AFMT_S16_LE
159#define AFMT_S16_OE AFMT_S16_BE
160#define AFMT_S24_NE AFMT_S24_LE
161#define AFMT_S24_OE AFMT_S24_BE
162#define AFMT_S32_NE AFMT_S32_LE
163#define AFMT_S32_OE AFMT_S32_BE
164#else
165#define AFMT_U16_NE AFMT_U16_BE
166#define AFMT_U16_OE AFMT_U16_LE
167#define AFMT_S16_NE AFMT_S16_BE
168#define AFMT_S16_OE AFMT_S16_LE
169#define AFMT_S24_NE AFMT_S24_BE
170#define AFMT_S24_OE AFMT_S24_LE
171#define AFMT_S32_NE AFMT_S32_BE
172#define AFMT_S32_OE AFMT_S32_LE
173#endif
174
175/* Aliases */
176#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT
177#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED
178#define SOUND_PCM_POST SNDCTL_DSP_POST
179#define SOUND_PCM_RESET SNDCTL_DSP_RESET
180#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC
181#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE
182#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT
183#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS
184#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT
185#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE
186#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE
187#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK
188#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS
189#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER
190#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER
191#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO
192#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR
193#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR
194#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF
195#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF
196
197/* Mixer defines */
198#define SOUND_MIXER_FIRST 0
199#define SOUND_MIXER_NRDEVICES 25
200
201#define SOUND_MIXER_VOLUME 0
202#define SOUND_MIXER_BASS 1
203#define SOUND_MIXER_TREBLE 2
204#define SOUND_MIXER_SYNTH 3
205#define SOUND_MIXER_PCM 4
206#define SOUND_MIXER_SPEAKER 5
207#define SOUND_MIXER_LINE 6
208#define SOUND_MIXER_MIC 7
209#define SOUND_MIXER_CD 8
210#define SOUND_MIXER_IMIX 9
211#define SOUND_MIXER_ALTPCM 10
212#define SOUND_MIXER_RECLEV 11
213#define SOUND_MIXER_IGAIN 12
214#define SOUND_MIXER_OGAIN 13
215#define SOUND_MIXER_LINE1 14
216#define SOUND_MIXER_LINE2 15
217#define SOUND_MIXER_LINE3 16
218#define SOUND_MIXER_DIGITAL1 17
219#define SOUND_MIXER_DIGITAL2 18
220#define SOUND_MIXER_DIGITAL3 19
221#define SOUND_MIXER_PHONEIN 20
222#define SOUND_MIXER_PHONEOUT 21
223#define SOUND_MIXER_VIDEO 22
224#define SOUND_MIXER_RADIO 23
225#define SOUND_MIXER_MONITOR 24
226
227#define SOUND_ONOFF_MIN 28
228#define SOUND_ONOFF_MAX 30
229
230#define SOUND_MIXER_NONE 31
231
232#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \
233 "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
234 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
235 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
236
237#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
238 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
239 "line1", "line2", "line3", "dig1", "dig2", "dig3", \
240 "phin", "phout", "video", "radio", "monitor"}
241
242#define SOUND_MIXER_RECSRC 0xff
243#define SOUND_MIXER_DEVMASK 0xfe
244#define SOUND_MIXER_RECMASK 0xfd
245#define SOUND_MIXER_CAPS 0xfc
246#define SOUND_CAP_EXCL_INPUT 1
247#define SOUND_MIXER_STEREODEVS 0xfb
248
249#define MIXER_READ(dev) _IOR('M', dev, int)
250
251#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
252#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
253#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
254#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
255#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
256
257#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
258#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
259#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
260#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
261#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
262#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
263#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
264#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
265#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
266#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
267#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
268#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
269#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
270#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
271#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
272#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
273#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
274
275#define MIXER_WRITE(dev) _IOW ('M', dev, int)
276#define MIXER_WRITE_R(dev) _IOWR('M', dev, int)
277
278#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
279#define SOUND_MIXER_WRITE_R_RECSRC MIXER_WRITE_R(SOUND_MIXER_RECSRC)
280
281#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
282#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
283#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
284#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
285#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
286#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
287#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
288#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
289#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
290#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
291#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
292#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
293#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
294#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
295#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
296#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
297#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
298
299#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
300#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
301#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
302#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
303#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
304#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
305#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
306#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
307#define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
308#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
309#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
310#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
311#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
312#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
313#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
314#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
315#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
316#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
317#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
318#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
319#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN)
320#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT)
321#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
322#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
323#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
324
325typedef struct mixer_info {
326 char id[16];
327 char name[32];
328 int modify_counter;
329 int fillers[10];
330} mixer_info;
331
332typedef struct _old_mixer_info {
333 char id[16];
334 char name[32];
335} _old_mixer_info;
336
337#define SOUND_MIXER_INFO _IOR('M', 101, mixer_info)
338#define SOUND_OLD_MIXER_INFO _IOR('M', 101, _old_mixer_info)
339
340#define OSS_GETVERSION _IOR ('M', 118, int)
341
342typedef struct audio_buf_info {
343 int fragments;
344 int fragstotal;
345 int fragsize;
346 int bytes;
347} audio_buf_info;
348
349typedef struct count_info {
350 int bytes;
351 int blocks;
352 int ptr;
353} count_info;
354
355typedef struct buffmem_desc {
356 unsigned int *buffer;
357 int size;
358} buffmem_desc;
359
360/* Some OSSv4 calls. */
361
362/* Why is yet more duplication necessary? Sigh. */
363#define OSS_OPEN_READ PCM_ENABLE_INPUT
364#define OSS_OPEN_WRITE PCM_ENABLE_OUTPUT
365#define OSS_OPEN_READWRITE (OSS_OPEN_READ|OSS_OPEN_WRITE)
366
367#define OSS_DEVNODE_SIZE 32
368#define OSS_LABEL_SIZE 16
369#define OSS_LONGNAME_SIZE 64
370#define OSS_MAX_AUDIO_DEVS 64
371
372#define SNDCTL_DSP_GETPLAYVOL _IOR ('P',27, uint)
373#define SNDCTL_DSP_SETPLAYVOL _IOW ('P',28, uint)
374#define SNDCTL_DSP_GETRECVOL _IOR ('P',29, uint)
375#define SNDCTL_DSP_SETRECVOL _IOW ('P',30, uint)
376#define SNDCTL_DSP_SKIP _IO ('P',31)
377#define SNDCTL_DSP_SILENCE _IO ('P',32)
378#define SNDCTL_DSP_COOKEDMODE _IOW ('P',33, int)
379#define SNDCTL_DSP_GETERROR _IOR ('P',34, struct audio_errinfo)
380#define SNDCTL_DSP_CURRENT_IPTR _IOR ('P',35, oss_count_t)
381#define SNDCTL_DSP_CURRENT_OPTR _IOR ('P',36, oss_count_t)
382#define SNDCTL_DSP_GET_RECSRC_NAMES _IOR ('P',37, oss_mixer_enuminfo)
383#define SNDCTL_DSP_GET_RECSRC _IOR ('P',38, int)
384#define SNDCTL_DSP_SET_RECSRC _IOWR ('P',38, int)
385#define SNDCTL_DSP_GET_PLAYTGT_NAMES _IOR ('P',39, oss_mixer_enuminfo)
386#define SNDCTL_DSP_GET_PLAYTGT _IOR ('P',40, int)
387#define SNDCTL_DSP_SET_PLAYTGT _IOWR ('P',40, int)
388
389#define SNDCTL_DSP_GET_CHNORDER _IOR ('P',42, unsigned long long)
390#define SNDCTL_DSP_SET_CHNORDER _IOWR ('P',42, unsigned long long)
391
392#define SNDCTL_DSP_HALT_OUTPUT _IO ('P',70)
393#define SNDCTL_DSP_RESET_OUTPUT SNDCTL_DSP_HALT_OUTPUT /* Old name */
394#define SNDCTL_DSP_HALT_INPUT _IO ('P',71)
395#define SNDCTL_DSP_RESET_INPUT SNDCTL_DSP_HALT_INPUT /* Old name */
396
397#define CHID_UNDEF 0
398#define CHID_L 1
399#define CHID_R 2
400#define CHID_C 3
401#define CHID_LFE 4
402#define CHID_LS 5
403#define CHID_RS 6
404#define CHID_LR 7
405#define CHID_RR 8
406#define CHNORDER_UNDEF 0x0000000000000000ULL
407#define CHNORDER_NORMAL 0x0000000087654321ULL
408
409typedef struct {
410 long long samples;
411 int fifo_samples;
412 int filler[32]; /* "Future use" */
413} oss_count_t;
414
415typedef struct audio_errinfo {
416 int play_underruns;
417 int rec_overruns;
418 unsigned int play_ptradjust; /* Obsolete */
419 unsigned int rec_ptradjust; /* Obsolete */
420 int play_errorcount; /* Unused */
421 int rec_errorcount; /* Unused */
422 int play_lasterror; /* Unused */
423 int rec_lasterror; /* Unused */
424 int play_errorparm; /* Unused */
425 int rec_errorparm; /* Unused */
426 int filler[16]; /* Unused */
427} audio_errinfo;
428
429typedef struct oss_sysinfo {
430 char product[32];
431 char version[32];
432 int versionnum;
433 char options[128]; /* Future use */
434 int numaudios;
435 int openedaudio[8]; /* Obsolete */
436 int numsynths; /* Obsolete */
437 int nummidis;
438 int numtimers;
439 int nummixers;
440 int openedmidi[8];
441 int numcards;
442 int numaudioengines;
443 char license[16];
444 char revision_info[256]; /* Internal Use */
445 int filler[172]; /* For expansion */
446} oss_sysinfo;
447
448typedef struct oss_audioinfo {
449 int dev; /* Set by caller */
450 char name[OSS_LONGNAME_SIZE];
451 int busy;
452 int pid;
453 int caps;
454 int iformats;
455 int oformats;
456 int magic; /* Unused */
457 char cmd[OSS_LONGNAME_SIZE];
458 int card_number;
459 int port_number;
460 int mixer_dev;
461 int legacy_device; /* Obsolete */
462 int enabled;
463 int flags; /* Reserved */
464 int min_rate;
465 int max_rate;
466 int min_channels;
467 int max_channels;
468 int binding; /* Reserved */
469 int rate_source;
470 char handle[32];
471#define OSS_MAX_SAMPLE_RATES 20
472 int nrates;
473 int rates[OSS_MAX_SAMPLE_RATES];
474 char song_name[OSS_LONGNAME_SIZE];
475 char label[OSS_LABEL_SIZE];
476 int latency; /* In usecs -1 = unknown */
477 char devnode[OSS_DEVNODE_SIZE];
478 int next_play_engine;
479 int next_rec_engine;
480 int filler[184]; /* For expansion */
481} oss_audioinfo;
482
483typedef struct oss_card_info {
484 int card;
485 char shortname[16];
486 char longname[128];
487 int flags;
488 char hw_info[400];
489 int intr_count;
490 int ack_count;
491 int filler[154];
492} oss_card_info;
493
494#define SNDCTL_SYSINFO _IOR ('X', 1, oss_sysinfo)
495#define OSS_SYSINFO SNDCTL_SYSINFO /* Old name */
496#define SNDCTL_MIX_NRMIX _IOR ('X',2, int)
497#define SNDCTL_MIX_NREXT _IOWR ('X',3, int)
498#define SNDCTL_MIX_EXTINFO _IOWR ('X',4, oss_mixext)
499#define SNDCTL_MIX_READ _IOWR ('X',5, oss_mixer_value)
500#define SNDCTL_MIX_WRITE _IOWR ('X',6, oss_mixer_value)
501#define SNDCTL_AUDIOINFO _IOWR ('X',7, oss_audioinfo)
502#define SNDCTL_MIX_ENUMINFO _IOWR ('X',8, oss_mixer_enuminfo)
503#define SNDCTL_MIXERINFO _IOWR ('X',10, oss_mixerinfo)
504#define SNDCTL_CARDINFO _IOWR ('X',11, oss_card_info)
505#define SNDCTL_ENGINEINFO _IOWR ('X',12, oss_audioinfo)
506#define SNDCTL_AUDIOINFO_EX _IOWR ('X',13, oss_audioinfo)
507#define SNDCTL_MIX_DESCRIPTION _IOWR ('X',14, oss_mixer_enuminfo)
508
509#define MIXT_DEVROOT 0 /* Used for default classes */
510#define MIXT_GROUP 1 /* Used for classes */
511#define MIXT_ONOFF 2 /* Used for mute controls */
512#define MIXT_ENUM 3 /* Used for enum controls */
513#define MIXT_MONOSLIDER 4 /* Used for mono and surround controls */
514#define MIXT_STEREOSLIDER 5 /* Used for stereo controls */
515#define MIXT_MESSAGE 6 /* OSS compat, unused on NetBSD */
516#define MIXT_MONOVU 7 /* OSS compat, unused on NetBSD */
517#define MIXT_STEREOVU 8 /* OSS compat, unused on NetBSD */
518#define MIXT_MONOPEAK 9 /* OSS compat, unused on NetBSD */
519#define MIXT_STEREOPEAK 10 /* OSS compat, unused on NetBSD */
520#define MIXT_RADIOGROUP 11 /* OSS compat, unused on NetBSD */
521#define MIXT_MARKER 12 /* OSS compat, unused on NetBSD */
522#define MIXT_VALUE 13 /* OSS compat, unused on NetBSD */
523#define MIXT_HEXVALUE 14 /* OSS compat, unused on NetBSD */
524#define MIXT_MONODB 15 /* OSS compat, unused on NetBSD */
525#define MIXT_STEREODB 16 /* OSS compat, unused on NetBSD */
526#define MIXT_SLIDER 17 /* OSS compat, unused on NetBSD */
527#define MIXT_3D 18 /* OSS compat, unused on NetBSD */
528#define MIXT_MONOSLIDER16 19 /* OSS compat, unused on NetBSD */
529#define MIXT_STEREOSLIDER16 20 /* OSS compat, unused on NetBSD */
530#define MIXT_MUTE 21 /* OSS compat, unused on NetBSD */
531/*
532 * Should be used for Set controls.
533 * In practice nothing uses this because it's "reserved for Sun's
534 * implementation".
535 */
536#define MIXT_ENUM_MULTI 22
537
538#define MIXF_READABLE 0x00000001 /* Value is readable: always true */
539#define MIXF_WRITEABLE 0x00000002 /* Value is writable: always true */
540#define MIXF_POLL 0x00000004 /* Can change between reads: always true */
541#define MIXF_HZ 0x00000008 /* OSS compat, unused on NetBSD */
542#define MIXF_STRING 0x00000010 /* OSS compat, unused on NetBSD */
543#define MIXF_DYNAMIC 0x00000010 /* OSS compat, unused on NetBSD */
544#define MIXF_OKFAIL 0x00000020 /* OSS compat, unused on NetBSD */
545#define MIXF_FLAT 0x00000040 /* OSS compat, unused on NetBSD */
546#define MIXF_LEGACY 0x00000080 /* OSS compat, unused on NetBSD */
547#define MIXF_CENTIBEL 0x00000100 /* OSS compat, unused on NetBSD */
548#define MIXF_DECIBEL 0x00000200 /* OSS compat, unused on NetBSD */
549#define MIXF_MAINVOL 0x00000400 /* OSS compat, unused on NetBSD */
550#define MIXF_PCMVOL 0x00000800 /* OSS compat, unused on NetBSD */
551#define MIXF_RECVOL 0x00001000 /* OSS compat, unused on NetBSD */
552#define MIXF_MONVOL 0x00002000 /* OSS compat, unused on NetBSD */
553#define MIXF_WIDE 0x00004000 /* OSS compat, unused on NetBSD */
554#define MIXF_DESCR 0x00008000 /* OSS compat, unused on NetBSD */
555#define MIXF_DISABLED 0x00010000 /* OSS compat, unused on NetBSD */
556
557/* None of the mixer capabilities are set on NetBSD. */
558#define MIXER_CAP_VIRTUAL 0x00000001 /* Virtual device */
559#define MIXER_CAP_LAYOUT_B 0x00000002 /* "Internal use only" */
560#define MIXER_CAP_NARROW 0x00000004 /* "Conserve screen space" */
561
562#define OSS_ID_SIZE 16
563typedef char oss_id_t[OSS_ID_SIZE];
564#define OSS_DEVNODE_SIZE 32
565typedef char oss_devnode_t[OSS_DEVNODE_SIZE];
566#define OSS_HANDLE_SIZE 32
567typedef char oss_handle_t[OSS_HANDLE_SIZE];
568#define OSS_LONGNAME_SIZE 64
569typedef char oss_longname_t[OSS_LONGNAME_SIZE];
570#define OSS_LABEL_SIZE 16
571typedef char oss_label_t[OSS_LABEL_SIZE];
572
573typedef struct oss_mixext_root {
574 oss_id_t id;
575 char name[48];
576} oss_mixext_root;
577
578typedef struct oss_mixerinfo {
579 int dev;
580 oss_id_t id;
581 char name[32];
582 int modify_counter;
583 int card_number;
584 int port_number;
585 oss_handle_t handle;
586 int magic; /* "Reserved for internal use" */
587 int enabled;
588 int caps;
589 int flags; /* "Reserved for internal use" */
590 int nrext;
591 int priority;
592 oss_devnode_t devnode;
593 int legacy_device;
594 int filler[245];
595} oss_mixerinfo;
596
597typedef struct oss_mixer_value {
598 int dev; /* Set by caller */
599 int ctrl; /* Set by caller */
600 int value;
601 int flags; /* Reserved for "future use" */
602 int timestamp;
603 int filler[8]; /* Reserved for "future use" */
604} oss_mixer_value;
605
606#define OSS_ENUM_MAXVALUE 255
607#define OSS_ENUM_STRINGSIZE 3000
608
609typedef struct oss_mixer_enuminfo {
610 int dev; /* Set by caller */
611 int ctrl; /* Set by caller */
612 int nvalues;
613 int version;
614 short strindex[OSS_ENUM_MAXVALUE];
615 char strings[OSS_ENUM_STRINGSIZE];
616} oss_mixer_enuminfo;
617
618typedef struct oss_mixext {
619 int dev;
620 int ctrl;
621 int type;
622 int maxvalue;
623 int minvalue;
624 int flags;
625 oss_id_t id;
626 int parent;
627 int dummy;
628 int timestamp;
629 char data[64];
630 unsigned char enum_present[32];
631 int control_no;
632 unsigned int desc;
633 char extname[32];
634 int update_counter;
635 int rgbcolor;
636 int filler[6];
637} oss_mixext;
638
639
640/*
641 * These are no-ops on FreeBSD, NetBSD, and Solaris,
642 * but are defined for compatibility with OSSv4.
643 */
644#define SNDCTL_SETSONG _IOW ('Y',2, oss_longname_t)
645#define SNDCTL_GETSONG _IOR ('Y',2, oss_longname_t)
646#define SNDCTL_SETNAME _IOW ('Y',3, oss_longname_t)
647#define SNDCTL_SETLABEL _IOW ('Y',4, oss_label_t)
648#define SNDCTL_GETLABEL _IOR ('Y',4, oss_label_t)
649
650#define ioctl _oss_ioctl
651/*
652 * If we already included <sys/ioctl.h>, then we define our own prototype,
653 * else we depend on <sys/ioctl.h> to do it for us. We do it this way, so
654 * that we don't define the prototype twice.
655 */
656#ifndef _SYS_IOCTL_H_
657#include <sys/ioctl.h>
658#else
659__BEGIN_DECLS
660int _oss_ioctl(int, unsigned long, ...);
661__END_DECLS
662#endif
663
664#endif /* !_SOUNDCARD_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/sys/soundcard.h created+664
......@@ -0,0 +1,664 @@
1/* $NetBSD: soundcard.h,v 1.34 2021/05/09 11:28:25 nia Exp $ */
2
3/*-
4 * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson and Nia Alarie.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*
33 * WARNING! WARNING!
34 * This is an Open Sound System compatibility layer.
35 * Use the Native NetBSD API in <sys/audioio.h> for developing new code,
36 * and this only for compiling programs written for other operating systems.
37 */
38
39#ifndef _SOUNDCARD_H_
40#define _SOUNDCARD_H_
41
42#ifndef SOUND_VERSION
43#define SOUND_VERSION 0x030001
44#endif
45
46#define SNDCTL_DSP_RESET _IO ('P', 0)
47#define SNDCTL_DSP_SYNC _IO ('P', 1)
48#define SNDCTL_DSP_SPEED _IOWR('P', 2, int)
49#define SOUND_PCM_READ_RATE _IOR ('P', 2, int)
50#define SNDCTL_DSP_STEREO _IOWR('P', 3, int)
51#define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int)
52#define SNDCTL_DSP_SETFMT _IOWR('P', 5, int)
53#define AFMT_QUERY 0x00000000
54#define AFMT_MU_LAW 0x00000001
55#define AFMT_A_LAW 0x00000002
56#define AFMT_IMA_ADPCM 0x00000004
57#define AFMT_U8 0x00000008
58#define AFMT_S16_LE 0x00000010
59#define AFMT_S16_BE 0x00000020
60#define AFMT_S8 0x00000040
61#define AFMT_U16_LE 0x00000080
62#define AFMT_U16_BE 0x00000100
63#define AFMT_MPEG 0x00000200 /* Not supported */
64#define AFMT_AC3 0x00000400
65#define AFMT_S24_LE 0x00000800 /* Not supported */
66#define AFMT_S24_BE 0x00001000 /* Not supported */
67#define AFMT_S32_LE 0x00002000
68#define AFMT_S32_BE 0x00004000
69#define AFMT_FLOAT 0x00010000 /* Not supported */
70#define AFMT_SPDIF_RAW 0x00020000 /* Not supported */
71#define AFMT_S24_PACKED 0x00040000 /* Not supported */
72#define AFMT_VORBIS 0x00080000 /* Not supported */
73#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
74#define SOUND_PCM_READ_BITS _IOR ('P', 5, int)
75#define SNDCTL_DSP_CHANNELS _IOWR('P', 6, int)
76#define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS
77#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int)
78#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int)
79#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int)
80#define SNDCTL_DSP_POST _IO ('P', 8)
81#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int)
82#define SNDCTL_DSP_SETFRAGMENT _IOWR('P', 10, int)
83#define SNDCTL_DSP_GETFMTS _IOR ('P', 11, int)
84#define SNDCTL_DSP_GETOSPACE _IOR ('P',12, struct audio_buf_info)
85#define SNDCTL_DSP_GETISPACE _IOR ('P',13, struct audio_buf_info)
86#define SNDCTL_DSP_NONBLOCK _IO ('P',14)
87#define SNDCTL_DSP_GETCAPS _IOR ('P',15, int)
88/* PCM_CAP_* were known as DSP_CAP_ before OSS 4.0 */
89# define DSP_CAP_REVISION PCM_CAP_REVISION
90# define DSP_CAP_DUPLEX PCM_CAP_DUPLEX
91# define DSP_CAP_REALTIME PCM_CAP_REALTIME
92# define DSP_CAP_BATCH PCM_CAP_BATCH
93# define DSP_CAP_COPROC PCM_CAP_COPROC
94# define DSP_CAP_TRIGGER PCM_CAP_TRIGGER
95# define DSP_CAP_MMAP PCM_CAP_MMAP
96# define DSP_CAP_INPUT PCM_CAP_INPUT
97# define DSP_CAP_OUTPUT PCM_CAP_OUTPUT
98# define DSP_CAP_MODEM PCM_CAP_MODEM
99# define DSP_CAP_HIDDEN PCM_CAP_HIDDEN
100# define DSP_CAP_VIRTUAL PCM_CAP_VIRTUAL
101# define DSP_CAP_ANALOGOUT PCM_CAP_ANALOGOUT
102# define DSP_CAP_ANALOGIN PCM_CAP_ANALOGIN
103# define DSP_CAP_DIGITALOUT PCM_CAP_DIGITALOUT
104# define DSP_CAP_DIGITALIN PCM_CAP_DIGITALIN
105# define DSP_CAP_ADMASK PCM_CAP_ADMASK
106# define DSP_CAP_FREERATE PCM_CAP_FREERATE
107# define DSP_CAP_MULTI PCM_CAP_MULTI
108# define DSP_CAP_BIND PCM_CAP_BIND
109# define DSP_CAP_SHADOW PCM_CAP_SHADOW
110# define PCM_CAP_REVISION 0x000000ff /* Unused in NetBSD */
111# define PCM_CAP_DUPLEX 0x00000100 /* Full duplex */
112# define PCM_CAP_REALTIME 0x00000200 /* Unused in NetBSD */
113# define PCM_CAP_BATCH 0x00000400 /* Unused in NetBSD */
114# define PCM_CAP_COPROC 0x00000800 /* Unused in NetBSD */
115# define PCM_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
116# define PCM_CAP_MMAP 0x00002000 /* Supports mmap() */
117# define PCM_CAP_INPUT 0x00004000 /* Recording device */
118# define PCM_CAP_OUTPUT 0x00008000 /* Playback device */
119# define PCM_CAP_MODEM 0x00010000 /* Unused in NetBSD */
120# define PCM_CAP_HIDDEN 0x00020000 /* Unused in NetBSD */
121# define PCM_CAP_VIRTUAL 0x00040000 /* Unused in NetBSD */
122# define PCM_CAP_MULTI 0x00080000 /* Simultaneous open() */
123# define PCM_CAP_ANALOGOUT 0x00100000 /* Unused in NetBSD */
124# define PCM_CAP_ANALOGIN 0x00200000 /* Unused in NetBSD */
125# define PCM_CAP_DIGITALOUT 0x00400000 /* Unused in NetBSD */
126# define PCM_CAP_DIGITALIN 0x00800000 /* Unused in NetBSD */
127# define PCM_CAP_ADMASK 0x00f00000 /* Unused in NetBSD */
128# define PCM_CAP_SPECIAL 0x01000000 /* Unused in NetBSD */
129# define PCM_CAP_FREERATE 0x10000000 /* Freely set rate */
130# define PCM_CAP_SHADOW 0x40000000 /* Unused in NetBSD */
131# define PCM_CAP_BIND 0x80000000 /* Unused in NetBSD */
132# define DSP_CH_ANY 0x00000000 /* No preferred mode */
133# define DSP_CH_MONO 0x02000000
134# define DSP_CH_STEREO 0x04000000
135# define DSP_CH_MULTI 0x06000000
136# define DSP_CH_MASK 0x06000000
137#define SNDCTL_DSP_GETTRIGGER _IOR ('P', 16, int)
138#define SNDCTL_DSP_SETTRIGGER _IOW ('P', 16, int)
139# define PCM_ENABLE_INPUT 0x00000001
140# define PCM_ENABLE_OUTPUT 0x00000002
141#define SNDCTL_DSP_GETIPTR _IOR ('P', 17, struct count_info)
142#define SNDCTL_DSP_GETOPTR _IOR ('P', 18, struct count_info)
143#define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, struct buffmem_desc)
144#define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, struct buffmem_desc)
145#define SNDCTL_DSP_SETSYNCRO _IO ('P', 21)
146#define SNDCTL_DSP_SETDUPLEX _IO ('P', 22)
147#define SNDCTL_DSP_PROFILE _IOW ('P', 23, int)
148#define SNDCTL_DSP_GETODELAY _IOR ('P', 23, int)
149#define APF_NORMAL 0
150#define APF_NETWORK 1
151#define APF_CPUINTENS 2
152
153/* Need native 16 bit format which depends on byte order */
154#include <machine/endian_machdep.h>
155#if _BYTE_ORDER == _LITTLE_ENDIAN
156#define AFMT_U16_NE AFMT_U16_LE
157#define AFMT_U16_OE AFMT_U16_BE
158#define AFMT_S16_NE AFMT_S16_LE
159#define AFMT_S16_OE AFMT_S16_BE
160#define AFMT_S24_NE AFMT_S24_LE
161#define AFMT_S24_OE AFMT_S24_BE
162#define AFMT_S32_NE AFMT_S32_LE
163#define AFMT_S32_OE AFMT_S32_BE
164#else
165#define AFMT_U16_NE AFMT_U16_BE
166#define AFMT_U16_OE AFMT_U16_LE
167#define AFMT_S16_NE AFMT_S16_BE
168#define AFMT_S16_OE AFMT_S16_LE
169#define AFMT_S24_NE AFMT_S24_BE
170#define AFMT_S24_OE AFMT_S24_LE
171#define AFMT_S32_NE AFMT_S32_BE
172#define AFMT_S32_OE AFMT_S32_LE
173#endif
174
175/* Aliases */
176#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT
177#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED
178#define SOUND_PCM_POST SNDCTL_DSP_POST
179#define SOUND_PCM_RESET SNDCTL_DSP_RESET
180#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC
181#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE
182#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT
183#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS
184#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT
185#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE
186#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE
187#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK
188#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS
189#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER
190#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER
191#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO
192#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR
193#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR
194#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF
195#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF
196
197/* Mixer defines */
198#define SOUND_MIXER_FIRST 0
199#define SOUND_MIXER_NRDEVICES 25
200
201#define SOUND_MIXER_VOLUME 0
202#define SOUND_MIXER_BASS 1
203#define SOUND_MIXER_TREBLE 2
204#define SOUND_MIXER_SYNTH 3
205#define SOUND_MIXER_PCM 4
206#define SOUND_MIXER_SPEAKER 5
207#define SOUND_MIXER_LINE 6
208#define SOUND_MIXER_MIC 7
209#define SOUND_MIXER_CD 8
210#define SOUND_MIXER_IMIX 9
211#define SOUND_MIXER_ALTPCM 10
212#define SOUND_MIXER_RECLEV 11
213#define SOUND_MIXER_IGAIN 12
214#define SOUND_MIXER_OGAIN 13
215#define SOUND_MIXER_LINE1 14
216#define SOUND_MIXER_LINE2 15
217#define SOUND_MIXER_LINE3 16
218#define SOUND_MIXER_DIGITAL1 17
219#define SOUND_MIXER_DIGITAL2 18
220#define SOUND_MIXER_DIGITAL3 19
221#define SOUND_MIXER_PHONEIN 20
222#define SOUND_MIXER_PHONEOUT 21
223#define SOUND_MIXER_VIDEO 22
224#define SOUND_MIXER_RADIO 23
225#define SOUND_MIXER_MONITOR 24
226
227#define SOUND_ONOFF_MIN 28
228#define SOUND_ONOFF_MAX 30
229
230#define SOUND_MIXER_NONE 31
231
232#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \
233 "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
234 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
235 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
236
237#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
238 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
239 "line1", "line2", "line3", "dig1", "dig2", "dig3", \
240 "phin", "phout", "video", "radio", "monitor"}
241
242#define SOUND_MIXER_RECSRC 0xff
243#define SOUND_MIXER_DEVMASK 0xfe
244#define SOUND_MIXER_RECMASK 0xfd
245#define SOUND_MIXER_CAPS 0xfc
246#define SOUND_CAP_EXCL_INPUT 1
247#define SOUND_MIXER_STEREODEVS 0xfb
248
249#define MIXER_READ(dev) _IOR('M', dev, int)
250
251#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
252#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
253#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
254#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
255#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
256
257#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
258#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
259#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
260#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
261#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
262#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
263#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
264#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
265#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
266#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
267#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
268#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
269#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
270#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
271#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
272#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
273#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
274
275#define MIXER_WRITE(dev) _IOW ('M', dev, int)
276#define MIXER_WRITE_R(dev) _IOWR('M', dev, int)
277
278#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
279#define SOUND_MIXER_WRITE_R_RECSRC MIXER_WRITE_R(SOUND_MIXER_RECSRC)
280
281#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
282#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
283#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
284#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
285#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
286#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
287#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
288#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
289#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
290#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
291#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
292#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
293#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
294#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
295#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
296#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
297#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
298
299#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
300#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
301#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
302#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
303#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
304#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
305#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
306#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
307#define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
308#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
309#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
310#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
311#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
312#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
313#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
314#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
315#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
316#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
317#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
318#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
319#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN)
320#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT)
321#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
322#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
323#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
324
325typedef struct mixer_info {
326 char id[16];
327 char name[32];
328 int modify_counter;
329 int fillers[10];
330} mixer_info;
331
332typedef struct _old_mixer_info {
333 char id[16];
334 char name[32];
335} _old_mixer_info;
336
337#define SOUND_MIXER_INFO _IOR('M', 101, mixer_info)
338#define SOUND_OLD_MIXER_INFO _IOR('M', 101, _old_mixer_info)
339
340#define OSS_GETVERSION _IOR ('M', 118, int)
341
342typedef struct audio_buf_info {
343 int fragments;
344 int fragstotal;
345 int fragsize;
346 int bytes;
347} audio_buf_info;
348
349typedef struct count_info {
350 int bytes;
351 int blocks;
352 int ptr;
353} count_info;
354
355typedef struct buffmem_desc {
356 unsigned int *buffer;
357 int size;
358} buffmem_desc;
359
360/* Some OSSv4 calls. */
361
362/* Why is yet more duplication necessary? Sigh. */
363#define OSS_OPEN_READ PCM_ENABLE_INPUT
364#define OSS_OPEN_WRITE PCM_ENABLE_OUTPUT
365#define OSS_OPEN_READWRITE (OSS_OPEN_READ|OSS_OPEN_WRITE)
366
367#define OSS_DEVNODE_SIZE 32
368#define OSS_LABEL_SIZE 16
369#define OSS_LONGNAME_SIZE 64
370#define OSS_MAX_AUDIO_DEVS 64
371
372#define SNDCTL_DSP_GETPLAYVOL _IOR ('P',27, uint)
373#define SNDCTL_DSP_SETPLAYVOL _IOW ('P',28, uint)
374#define SNDCTL_DSP_GETRECVOL _IOR ('P',29, uint)
375#define SNDCTL_DSP_SETRECVOL _IOW ('P',30, uint)
376#define SNDCTL_DSP_SKIP _IO ('P',31)
377#define SNDCTL_DSP_SILENCE _IO ('P',32)
378#define SNDCTL_DSP_COOKEDMODE _IOW ('P',33, int)
379#define SNDCTL_DSP_GETERROR _IOR ('P',34, struct audio_errinfo)
380#define SNDCTL_DSP_CURRENT_IPTR _IOR ('P',35, oss_count_t)
381#define SNDCTL_DSP_CURRENT_OPTR _IOR ('P',36, oss_count_t)
382#define SNDCTL_DSP_GET_RECSRC_NAMES _IOR ('P',37, oss_mixer_enuminfo)
383#define SNDCTL_DSP_GET_RECSRC _IOR ('P',38, int)
384#define SNDCTL_DSP_SET_RECSRC _IOWR ('P',38, int)
385#define SNDCTL_DSP_GET_PLAYTGT_NAMES _IOR ('P',39, oss_mixer_enuminfo)
386#define SNDCTL_DSP_GET_PLAYTGT _IOR ('P',40, int)
387#define SNDCTL_DSP_SET_PLAYTGT _IOWR ('P',40, int)
388
389#define SNDCTL_DSP_GET_CHNORDER _IOR ('P',42, unsigned long long)
390#define SNDCTL_DSP_SET_CHNORDER _IOWR ('P',42, unsigned long long)
391
392#define SNDCTL_DSP_HALT_OUTPUT _IO ('P',70)
393#define SNDCTL_DSP_RESET_OUTPUT SNDCTL_DSP_HALT_OUTPUT /* Old name */
394#define SNDCTL_DSP_HALT_INPUT _IO ('P',71)
395#define SNDCTL_DSP_RESET_INPUT SNDCTL_DSP_HALT_INPUT /* Old name */
396
397#define CHID_UNDEF 0
398#define CHID_L 1
399#define CHID_R 2
400#define CHID_C 3
401#define CHID_LFE 4
402#define CHID_LS 5
403#define CHID_RS 6
404#define CHID_LR 7
405#define CHID_RR 8
406#define CHNORDER_UNDEF 0x0000000000000000ULL
407#define CHNORDER_NORMAL 0x0000000087654321ULL
408
409typedef struct {
410 long long samples;
411 int fifo_samples;
412 int filler[32]; /* "Future use" */
413} oss_count_t;
414
415typedef struct audio_errinfo {
416 int play_underruns;
417 int rec_overruns;
418 unsigned int play_ptradjust; /* Obsolete */
419 unsigned int rec_ptradjust; /* Obsolete */
420 int play_errorcount; /* Unused */
421 int rec_errorcount; /* Unused */
422 int play_lasterror; /* Unused */
423 int rec_lasterror; /* Unused */
424 int play_errorparm; /* Unused */
425 int rec_errorparm; /* Unused */
426 int filler[16]; /* Unused */
427} audio_errinfo;
428
429typedef struct oss_sysinfo {
430 char product[32];
431 char version[32];
432 int versionnum;
433 char options[128]; /* Future use */
434 int numaudios;
435 int openedaudio[8]; /* Obsolete */
436 int numsynths; /* Obsolete */
437 int nummidis;
438 int numtimers;
439 int nummixers;
440 int openedmidi[8];
441 int numcards;
442 int numaudioengines;
443 char license[16];
444 char revision_info[256]; /* Internal Use */
445 int filler[172]; /* For expansion */
446} oss_sysinfo;
447
448typedef struct oss_audioinfo {
449 int dev; /* Set by caller */
450 char name[OSS_LONGNAME_SIZE];
451 int busy;
452 int pid;
453 int caps;
454 int iformats;
455 int oformats;
456 int magic; /* Unused */
457 char cmd[OSS_LONGNAME_SIZE];
458 int card_number;
459 int port_number;
460 int mixer_dev;
461 int legacy_device; /* Obsolete */
462 int enabled;
463 int flags; /* Reserved */
464 int min_rate;
465 int max_rate;
466 int min_channels;
467 int max_channels;
468 int binding; /* Reserved */
469 int rate_source;
470 char handle[32];
471#define OSS_MAX_SAMPLE_RATES 20
472 int nrates;
473 int rates[OSS_MAX_SAMPLE_RATES];
474 char song_name[OSS_LONGNAME_SIZE];
475 char label[OSS_LABEL_SIZE];
476 int latency; /* In usecs -1 = unknown */
477 char devnode[OSS_DEVNODE_SIZE];
478 int next_play_engine;
479 int next_rec_engine;
480 int filler[184]; /* For expansion */
481} oss_audioinfo;
482
483typedef struct oss_card_info {
484 int card;
485 char shortname[16];
486 char longname[128];
487 int flags;
488 char hw_info[400];
489 int intr_count;
490 int ack_count;
491 int filler[154];
492} oss_card_info;
493
494#define SNDCTL_SYSINFO _IOR ('X', 1, oss_sysinfo)
495#define OSS_SYSINFO SNDCTL_SYSINFO /* Old name */
496#define SNDCTL_MIX_NRMIX _IOR ('X',2, int)
497#define SNDCTL_MIX_NREXT _IOWR ('X',3, int)
498#define SNDCTL_MIX_EXTINFO _IOWR ('X',4, oss_mixext)
499#define SNDCTL_MIX_READ _IOWR ('X',5, oss_mixer_value)
500#define SNDCTL_MIX_WRITE _IOWR ('X',6, oss_mixer_value)
501#define SNDCTL_AUDIOINFO _IOWR ('X',7, oss_audioinfo)
502#define SNDCTL_MIX_ENUMINFO _IOWR ('X',8, oss_mixer_enuminfo)
503#define SNDCTL_MIXERINFO _IOWR ('X',10, oss_mixerinfo)
504#define SNDCTL_CARDINFO _IOWR ('X',11, oss_card_info)
505#define SNDCTL_ENGINEINFO _IOWR ('X',12, oss_audioinfo)
506#define SNDCTL_AUDIOINFO_EX _IOWR ('X',13, oss_audioinfo)
507#define SNDCTL_MIX_DESCRIPTION _IOWR ('X',14, oss_mixer_enuminfo)
508
509#define MIXT_DEVROOT 0 /* Used for default classes */
510#define MIXT_GROUP 1 /* Used for classes */
511#define MIXT_ONOFF 2 /* Used for mute controls */
512#define MIXT_ENUM 3 /* Used for enum controls */
513#define MIXT_MONOSLIDER 4 /* Used for mono and surround controls */
514#define MIXT_STEREOSLIDER 5 /* Used for stereo controls */
515#define MIXT_MESSAGE 6 /* OSS compat, unused on NetBSD */
516#define MIXT_MONOVU 7 /* OSS compat, unused on NetBSD */
517#define MIXT_STEREOVU 8 /* OSS compat, unused on NetBSD */
518#define MIXT_MONOPEAK 9 /* OSS compat, unused on NetBSD */
519#define MIXT_STEREOPEAK 10 /* OSS compat, unused on NetBSD */
520#define MIXT_RADIOGROUP 11 /* OSS compat, unused on NetBSD */
521#define MIXT_MARKER 12 /* OSS compat, unused on NetBSD */
522#define MIXT_VALUE 13 /* OSS compat, unused on NetBSD */
523#define MIXT_HEXVALUE 14 /* OSS compat, unused on NetBSD */
524#define MIXT_MONODB 15 /* OSS compat, unused on NetBSD */
525#define MIXT_STEREODB 16 /* OSS compat, unused on NetBSD */
526#define MIXT_SLIDER 17 /* OSS compat, unused on NetBSD */
527#define MIXT_3D 18 /* OSS compat, unused on NetBSD */
528#define MIXT_MONOSLIDER16 19 /* OSS compat, unused on NetBSD */
529#define MIXT_STEREOSLIDER16 20 /* OSS compat, unused on NetBSD */
530#define MIXT_MUTE 21 /* OSS compat, unused on NetBSD */
531/*
532 * Should be used for Set controls.
533 * In practice nothing uses this because it's "reserved for Sun's
534 * implementation".
535 */
536#define MIXT_ENUM_MULTI 22
537
538#define MIXF_READABLE 0x00000001 /* Value is readable: always true */
539#define MIXF_WRITEABLE 0x00000002 /* Value is writable: always true */
540#define MIXF_POLL 0x00000004 /* Can change between reads: always true */
541#define MIXF_HZ 0x00000008 /* OSS compat, unused on NetBSD */
542#define MIXF_STRING 0x00000010 /* OSS compat, unused on NetBSD */
543#define MIXF_DYNAMIC 0x00000010 /* OSS compat, unused on NetBSD */
544#define MIXF_OKFAIL 0x00000020 /* OSS compat, unused on NetBSD */
545#define MIXF_FLAT 0x00000040 /* OSS compat, unused on NetBSD */
546#define MIXF_LEGACY 0x00000080 /* OSS compat, unused on NetBSD */
547#define MIXF_CENTIBEL 0x00000100 /* OSS compat, unused on NetBSD */
548#define MIXF_DECIBEL 0x00000200 /* OSS compat, unused on NetBSD */
549#define MIXF_MAINVOL 0x00000400 /* OSS compat, unused on NetBSD */
550#define MIXF_PCMVOL 0x00000800 /* OSS compat, unused on NetBSD */
551#define MIXF_RECVOL 0x00001000 /* OSS compat, unused on NetBSD */
552#define MIXF_MONVOL 0x00002000 /* OSS compat, unused on NetBSD */
553#define MIXF_WIDE 0x00004000 /* OSS compat, unused on NetBSD */
554#define MIXF_DESCR 0x00008000 /* OSS compat, unused on NetBSD */
555#define MIXF_DISABLED 0x00010000 /* OSS compat, unused on NetBSD */
556
557/* None of the mixer capabilities are set on NetBSD. */
558#define MIXER_CAP_VIRTUAL 0x00000001 /* Virtual device */
559#define MIXER_CAP_LAYOUT_B 0x00000002 /* "Internal use only" */
560#define MIXER_CAP_NARROW 0x00000004 /* "Conserve screen space" */
561
562#define OSS_ID_SIZE 16
563typedef char oss_id_t[OSS_ID_SIZE];
564#define OSS_DEVNODE_SIZE 32
565typedef char oss_devnode_t[OSS_DEVNODE_SIZE];
566#define OSS_HANDLE_SIZE 32
567typedef char oss_handle_t[OSS_HANDLE_SIZE];
568#define OSS_LONGNAME_SIZE 64
569typedef char oss_longname_t[OSS_LONGNAME_SIZE];
570#define OSS_LABEL_SIZE 16
571typedef char oss_label_t[OSS_LABEL_SIZE];
572
573typedef struct oss_mixext_root {
574 oss_id_t id;
575 char name[48];
576} oss_mixext_root;
577
578typedef struct oss_mixerinfo {
579 int dev;
580 oss_id_t id;
581 char name[32];
582 int modify_counter;
583 int card_number;
584 int port_number;
585 oss_handle_t handle;
586 int magic; /* "Reserved for internal use" */
587 int enabled;
588 int caps;
589 int flags; /* "Reserved for internal use" */
590 int nrext;
591 int priority;
592 oss_devnode_t devnode;
593 int legacy_device;
594 int filler[245];
595} oss_mixerinfo;
596
597typedef struct oss_mixer_value {
598 int dev; /* Set by caller */
599 int ctrl; /* Set by caller */
600 int value;
601 int flags; /* Reserved for "future use" */
602 int timestamp;
603 int filler[8]; /* Reserved for "future use" */
604} oss_mixer_value;
605
606#define OSS_ENUM_MAXVALUE 255
607#define OSS_ENUM_STRINGSIZE 3000
608
609typedef struct oss_mixer_enuminfo {
610 int dev; /* Set by caller */
611 int ctrl; /* Set by caller */
612 int nvalues;
613 int version;
614 short strindex[OSS_ENUM_MAXVALUE];
615 char strings[OSS_ENUM_STRINGSIZE];
616} oss_mixer_enuminfo;
617
618typedef struct oss_mixext {
619 int dev;
620 int ctrl;
621 int type;
622 int maxvalue;
623 int minvalue;
624 int flags;
625 oss_id_t id;
626 int parent;
627 int dummy;
628 int timestamp;
629 char data[64];
630 unsigned char enum_present[32];
631 int control_no;
632 unsigned int desc;
633 char extname[32];
634 int update_counter;
635 int rgbcolor;
636 int filler[6];
637} oss_mixext;
638
639
640/*
641 * These are no-ops on FreeBSD, NetBSD, and Solaris,
642 * but are defined for compatibility with OSSv4.
643 */
644#define SNDCTL_SETSONG _IOW ('Y',2, oss_longname_t)
645#define SNDCTL_GETSONG _IOR ('Y',2, oss_longname_t)
646#define SNDCTL_SETNAME _IOW ('Y',3, oss_longname_t)
647#define SNDCTL_SETLABEL _IOW ('Y',4, oss_label_t)
648#define SNDCTL_GETLABEL _IOR ('Y',4, oss_label_t)
649
650#define ioctl _oss_ioctl
651/*
652 * If we already included <sys/ioctl.h>, then we define our own prototype,
653 * else we depend on <sys/ioctl.h> to do it for us. We do it this way, so
654 * that we don't define the prototype twice.
655 */
656#ifndef _SYS_IOCTL_H_
657#include <sys/ioctl.h>
658#else
659__BEGIN_DECLS
660int _oss_ioctl(int, unsigned long, ...);
661__END_DECLS
662#endif
663
664#endif /* !_SOUNDCARD_H_ */
\ No newline at end of file
lib/libc/include/powerpc-netbsd-eabi/machine/bswap.h created+3
......@@ -0,0 +1,3 @@
1/* $NetBSD: bswap.h,v 1.1 2002/12/09 12:15:58 scw Exp $ */
2
3#include <powerpc/bswap.h>
\ No newline at end of file
lib/libc/include/powerpc-netbsd-eabi/machine/endian_machdep.h created+3
......@@ -0,0 +1,3 @@
1/* $NetBSD: endian_machdep.h,v 1.1 2002/12/09 12:16:02 scw Exp $ */
2
3#include <powerpc/endian_machdep.h>
\ No newline at end of file
lib/libc/include/powerpc-netbsd-eabi/machine/rwlock.h created+3
......@@ -0,0 +1,3 @@
1/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:03 ad Exp $ */
2
3#include <powerpc/rwlock.h>
\ No newline at end of file
lib/libc/include/sparc-netbsd-none/machine/bswap.h deleted-8
......@@ -1,8 +0,0 @@
1/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:55 simonb Exp $ */
2
3#ifndef _MACHINE_BSWAP_H_
4#define _MACHINE_BSWAP_H_
5
6#include <sys/bswap.h>
7
8#endif /* !_MACHINE_BSWAP_H_ */
\ No newline at end of file
lib/libc/include/sparc-netbsd-none/machine/endian_machdep.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:25 mycroft Exp $ */
2
3#define _BYTE_ORDER _BIG_ENDIAN
\ No newline at end of file
lib/libc/include/sparc-netbsd-none/machine/rwlock.h deleted-1
......@@ -1 +0,0 @@
1/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:53 riastradh Exp $ */
\ No newline at end of file
lib/libc/include/sparc64-netbsd-none/machine/bswap.h deleted-8
......@@ -1,8 +0,0 @@
1/* $NetBSD: bswap.h,v 1.2 1999/08/21 05:39:55 simonb Exp $ */
2
3#ifndef _MACHINE_BSWAP_H_
4#define _MACHINE_BSWAP_H_
5
6#include <sys/bswap.h>
7
8#endif /* !_MACHINE_BSWAP_H_ */
\ No newline at end of file
lib/libc/include/sparc64-netbsd-none/machine/endian_machdep.h deleted-3
......@@ -1,3 +0,0 @@
1/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:25 mycroft Exp $ */
2
3#define _BYTE_ORDER _BIG_ENDIAN
\ No newline at end of file
lib/libc/include/sparc64-netbsd-none/machine/rwlock.h deleted-1
......@@ -1 +0,0 @@
1/* $NetBSD: rwlock.h,v 1.6 2019/11/29 20:04:53 riastradh Exp $ */
\ No newline at end of file