Nintendo switch support (#8069)
* Add config section for Nintendo Switch * Add compiler configuration for Nintendo Switch and it's CPU * Add specific lib code for Nintendo Switch * Add GC support for Nintendo Switch * Update changelog for Nintendo Switch * Update changelog with more info about fixed paths * Cleaned up GC memory management a bit * Relocate docs for Switch * Rename aarch64NoneElfGcc to nintendoSwitchGCC * Remove armv8a57 * Fix installer.ini * Reuse code in linux and amd64 * Add posix defs for nintendo switch * Add more defined sections for nintendo switch * Remove old comment * Add what's not supported for Nintendo Switch docs * Make nintendoswitch == posix * Remove DEVKITPRO references from nim.cfg * Make PR extccomp changes * Remove Result type alias * Add separate switch consts file * Update docs for nintendo switch * Fix travis errors with undefined consts and add correct wait.h procs
This commit is contained in:
parent
b74b16ffde
commit
559a7615ad
21 changed files with 1352 additions and 43 deletions
|
|
@ -45,7 +45,7 @@ when defined(windows):
|
|||
SIGTERM = cint(15)
|
||||
elif defined(macosx) or defined(linux) or defined(freebsd) or
|
||||
defined(openbsd) or defined(netbsd) or defined(solaris) or
|
||||
defined(dragonfly):
|
||||
defined(dragonfly) or defined(nintendoswitch):
|
||||
const
|
||||
SIGABRT = cint(6)
|
||||
SIGFPE = cint(8)
|
||||
|
|
|
|||
|
|
@ -167,6 +167,24 @@ elif defined(genode):
|
|||
proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr {.
|
||||
error: "nimGetProcAddr not implemented".}
|
||||
|
||||
elif defined(nintendoswitch):
|
||||
proc nimUnloadLibrary(lib: LibHandle) =
|
||||
stderr.rawWrite("nimUnLoadLibrary not implemented")
|
||||
stderr.rawWrite("\n")
|
||||
quit(1)
|
||||
|
||||
proc nimLoadLibrary(path: string): LibHandle =
|
||||
stderr.rawWrite("nimLoadLibrary not implemented")
|
||||
stderr.rawWrite("\n")
|
||||
quit(1)
|
||||
|
||||
|
||||
proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
|
||||
stderr.rawWrite("nimGetProAddr not implemented")
|
||||
stderr.write(name)
|
||||
stderr.rawWrite("\n")
|
||||
quit(1)
|
||||
|
||||
else:
|
||||
{.error: "no implementation for dyncalls".}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,43 @@ when defined(emscripten):
|
|||
elif defined(genode):
|
||||
include genode/alloc # osAllocPages, osTryAllocPages, osDeallocPages
|
||||
|
||||
elif defined(nintendoswitch):
|
||||
import nintendoswitch/switch_memory
|
||||
|
||||
var
|
||||
stack: pointer
|
||||
|
||||
proc alignSize(size: int): int =
|
||||
(size + 0x00000FFF) and not 0x00000FFF
|
||||
|
||||
proc freeMem(p: pointer, msize: int) =
|
||||
let size = alignSize(msize)
|
||||
discard svcUnmapMemory(p, stack, size.uint64)
|
||||
virtmemFreeMap(p, size.csize)
|
||||
free(stack)
|
||||
|
||||
proc osAllocPages(msize: int): pointer {.inline.} =
|
||||
let size = alignSize(msize)
|
||||
stack = memalign(0x1000, size)
|
||||
result = virtmemReserveMap(size.csize)
|
||||
let rc = svcMapMemory(result, stack, size.uint64)
|
||||
if rc.uint32 != 0:
|
||||
freeMem(result, size)
|
||||
raiseOutOfMem()
|
||||
|
||||
proc osTryAllocPages(msize: int): pointer {.inline.} =
|
||||
let size = alignSize(msize)
|
||||
stack = memalign(0x1000, size)
|
||||
result = virtmemReserveMap(size.csize)
|
||||
let rc = svcMapMemory(result, stack, size.uint64)
|
||||
if rc.uint32 != 0:
|
||||
freeMem(result, size)
|
||||
result = nil
|
||||
|
||||
proc osDeallocPages(p: pointer, size: int) {.inline.} =
|
||||
when reallyOsDealloc:
|
||||
freeMem(p, size)
|
||||
|
||||
elif defined(posix):
|
||||
const
|
||||
PROT_READ = 1 # page can be read
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type
|
|||
none, dos, windows, os2, linux, morphos, skyos, solaris,
|
||||
irix, netbsd, freebsd, openbsd, aix, palmos, qnx, amiga,
|
||||
atari, netware, macos, macosx, haiku, android, js, nimVM,
|
||||
standalone
|
||||
standalone, nintendoswitch
|
||||
|
||||
const
|
||||
targetOS* = when defined(windows): OsPlatform.windows
|
||||
|
|
@ -64,6 +64,7 @@ const
|
|||
elif defined(js): OsPlatform.js
|
||||
elif defined(nimVM): OsPlatform.nimVM
|
||||
elif defined(standalone): OsPlatform.standalone
|
||||
elif defined(nintendoswitch): OsPlatform.nintendoswitch
|
||||
else: OsPlatform.none
|
||||
## the OS this program will run on.
|
||||
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ proc setStdIoUnbuffered() =
|
|||
when declared(stdout):
|
||||
proc echoBinSafe(args: openArray[string]) {.compilerProc.} =
|
||||
# flockfile deadlocks some versions of Android 5.x.x
|
||||
when not defined(windows) and not defined(android):
|
||||
when not defined(windows) and not defined(android) and not defined(nintendoswitch):
|
||||
proc flockfile(f: File) {.importc, noDecl.}
|
||||
proc funlockfile(f: File) {.importc, noDecl.}
|
||||
flockfile(stdout)
|
||||
|
|
@ -428,7 +428,7 @@ when declared(stdout):
|
|||
const linefeed = "\n" # can be 1 or more chars
|
||||
discard c_fwrite(linefeed.cstring, linefeed.len, 1, stdout)
|
||||
discard c_fflush(stdout)
|
||||
when not defined(windows) and not defined(android):
|
||||
when not defined(windows) and not defined(android) and not defined(nintendoswitch):
|
||||
funlockfile(stdout)
|
||||
|
||||
{.pop.}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ else:
|
|||
else:
|
||||
type Time = int
|
||||
|
||||
when defined(linux) and defined(amd64):
|
||||
when (defined(linux) or defined(nintendoswitch)) and defined(amd64):
|
||||
type
|
||||
SysThread* {.importc: "pthread_t",
|
||||
header: "<sys/types.h>" .} = distinct culong
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue