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