made lua debugger stop crying and added more docs
This commit is contained in:
9
.vscode/settings.json
vendored
Normal file
9
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Lua.diagnostics.globals": [
|
||||||
|
"isEqualToAny",
|
||||||
|
"isEqualToAll",
|
||||||
|
"syscall",
|
||||||
|
"printf",
|
||||||
|
"printInline"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
syscall.TTY_clear()
|
syscall.TTY_clear()
|
||||||
--syscall.TTY_setTextColor(2)
|
syscall.TTY_setTextColor(1)
|
||||||
syscall.TTY_setCursorPos(1, 1)
|
syscall.TTY_setCursorPos(1, 1)
|
||||||
syscall.TTY_print("HyperionOS Bash Shell")
|
syscall.TTY_print("HyperionOS Bash Shell")
|
||||||
|
local str=""
|
||||||
while true do
|
while true do
|
||||||
local event = syscall.IO_getEventAny()
|
local event = syscall.IO_getEventAny()
|
||||||
if event then
|
if event then
|
||||||
syscall.TTY_print(table.serialize(event))
|
if event[1]=="keyTyped" then
|
||||||
|
if event[3]=="\b" then
|
||||||
|
str=str:sub(1,#str-1)
|
||||||
|
printInline("\b")
|
||||||
|
else
|
||||||
|
str=str..event[3]
|
||||||
|
printInline(event[3])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
--:Minify:--
|
--:Minify:--
|
||||||
local BOOT_DRIVE_PATH="/$"
|
local BOOT_DRIVE_PATH="/$"
|
||||||
|
---@diagnostic disable-next-line: undefined-global
|
||||||
local term = term
|
local term = term
|
||||||
local os = os
|
local os = os
|
||||||
-- Function to write text to the terminal with special character handling
|
-- Function to write text to the terminal with special character handling
|
||||||
@@ -237,6 +238,7 @@ local ok, err = xpcall(function()
|
|||||||
|
|
||||||
-- Make the kernel coroutine so we can hook its execution
|
-- Make the kernel coroutine so we can hook its execution
|
||||||
local kernelCoro = coroutine.create(function()
|
local kernelCoro = coroutine.create(function()
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
local ok, err = xpcall(Kernel, debug.traceback, apis, initFs, "cct", "/sbin/init", {
|
local ok, err = xpcall(Kernel, debug.traceback, apis, initFs, "cct", "/sbin/init", {
|
||||||
print=function(_,text) write(text.."\n") end,
|
print=function(_,text) write(text.."\n") end,
|
||||||
printInline=function(_,text) write(text) end,
|
printInline=function(_,text) write(text) end,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
--:Minify:--
|
||||||
local apis=...
|
local apis=...
|
||||||
local keys=apis.keys
|
local keys=apis.keys
|
||||||
local tKeys = {}
|
local tKeys = {}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ local lua = {
|
|||||||
_G=true
|
_G=true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local apis={}
|
||||||
for i,v in pairs(_G) do
|
for i,v in pairs(_G) do
|
||||||
if not lua[i] or lua[i]==nil then
|
if not lua[i] or lua[i]==nil then
|
||||||
apis[i]=v
|
apis[i]=v
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ end
|
|||||||
|
|
||||||
function kernel.PANIC(msg)
|
function kernel.PANIC(msg)
|
||||||
if kernel.status~="Panic" then
|
if kernel.status~="Panic" then
|
||||||
|
kernel.exitMain = true
|
||||||
kernel.log("PANIC: "..msg, "PANIC")
|
kernel.log("PANIC: "..msg, "PANIC")
|
||||||
pcall(kernel["saveLog"])
|
pcall(kernel["saveLog"])
|
||||||
kernel.status="Panic"
|
kernel.status="Panic"
|
||||||
@@ -117,6 +118,7 @@ if not initCfgFunc then
|
|||||||
kernel.PANIC("Failed to load /boot/boot.cfg: "..tostring(err))
|
kernel.PANIC("Failed to load /boot/boot.cfg: "..tostring(err))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
local initCfgStatus, config = pcall(initCfgFunc)
|
local initCfgStatus, config = pcall(initCfgFunc)
|
||||||
if not initCfgStatus then
|
if not initCfgStatus then
|
||||||
kernel.PANIC("Error in /boot/boot.cfg: "..tostring(config))
|
kernel.PANIC("Error in /boot/boot.cfg: "..tostring(config))
|
||||||
@@ -218,6 +220,14 @@ kernel.kernelTask = {
|
|||||||
}
|
}
|
||||||
kernel.currentTask = kernel.kernelTask
|
kernel.currentTask = kernel.kernelTask
|
||||||
|
|
||||||
|
function kernel.shutdown()
|
||||||
|
kernel.computer:shutdown()
|
||||||
|
end
|
||||||
|
|
||||||
|
function kernel.reboot()
|
||||||
|
kernel.computer:reboot()
|
||||||
|
end
|
||||||
|
|
||||||
kernel.syscalls["OS_time"]=function() return kernel.computer:time() end
|
kernel.syscalls["OS_time"]=function() return kernel.computer:time() end
|
||||||
kernel.syscalls["OS_log"]=kernel.log
|
kernel.syscalls["OS_log"]=kernel.log
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ function type(object, trueType)
|
|||||||
else
|
else
|
||||||
if oldtype(oldgetmetatable(object))=="table" then
|
if oldtype(oldgetmetatable(object))=="table" then
|
||||||
local metatable = oldgetmetatable(object)
|
local metatable = oldgetmetatable(object)
|
||||||
|
---@diagnostic disable-next-line: need-check-nil
|
||||||
if metatable.__type then return metatable.__type end
|
if metatable.__type then return metatable.__type end
|
||||||
else
|
else
|
||||||
return "table"
|
return "table"
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ kernel.processes.keventd = function()
|
|||||||
while true do
|
while true do
|
||||||
local event = {kernel.computer:getMachineEvent()}
|
local event = {kernel.computer:getMachineEvent()}
|
||||||
if event[1] then
|
if event[1] then
|
||||||
|
if event[1]=="keyTyped" then
|
||||||
|
if event[3]=="\x1b^s" then
|
||||||
|
kernel.shutdown()
|
||||||
|
elseif event[3]=="\x1b^r" then
|
||||||
|
kernel.reboot()
|
||||||
|
end
|
||||||
|
end
|
||||||
events.push(event)
|
events.push(event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function sys.spawn(func, name, envars, args, tgid)
|
|||||||
tasks[tostring(id)].exit=err
|
tasks[tostring(id)].exit=err
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
name=name or "task"..tostring(id),
|
name=name or ("task"..tostring(id)),
|
||||||
envars=envars or {},
|
envars=envars or {},
|
||||||
args=args or {},
|
args=args or {},
|
||||||
status="R",
|
status="R",
|
||||||
|
|||||||
14
docs/kernel/Syscalls/README.md
Normal file
14
docs/kernel/Syscalls/README.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Syscalls
|
||||||
|
---
|
||||||
|
|
||||||
|
Syscalls allow for tasks to request somthing only the kernel can do (ex: reading a file).
|
||||||
|
|
||||||
|
Syscalls can be called in 2 ways, ```syscall.{id / name}(args...)``` or ```coroutine.yeild("syscall", {name / id}, args...)```.
|
||||||
|
|
||||||
|
Syscalls are also implemented as functions in
|
||||||
|
```
|
||||||
|
sleep(ms)
|
||||||
|
print(...)
|
||||||
|
printInline(...)
|
||||||
|
printf(fmt, ...)
|
||||||
|
```
|
||||||
@@ -21,4 +21,9 @@ maxFilesPerTask<num>
|
|||||||
preempt<bool>
|
preempt<bool>
|
||||||
enable/disable preemptive multitasking
|
enable/disable preemptive multitasking
|
||||||
|
|
||||||
|
debugSyscalls<bool>
|
||||||
|
logs syscalls and thier return values aswell as what task executed them
|
||||||
|
|
||||||
|
logTaskExit<bool>
|
||||||
|
logs task exits and errors
|
||||||
```
|
```
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# Drivers
|
|
||||||
---
|
|
||||||
|
|
||||||
Hyperion OS supports many driver types to allow it to run on any hardware
|
|
||||||
```
|
|
||||||
Driver types
|
|
||||||
tty - Supports basic teletype devices
|
|
||||||
gpio - Supports things like redstone
|
|
||||||
runner - Kernel level programs (no api)
|
|
||||||
timer - Timers and time related
|
|
||||||
periph - Basic peripheral info
|
|
||||||
gfx - PixelScreens
|
|
||||||
modem - networking
|
|
||||||
```
|
|
||||||
Hyperion also has a base driver api
|
|
||||||
```
|
|
||||||
Driver API
|
|
||||||
name - Name of driver
|
|
||||||
type - Type of driver
|
|
||||||
load - loading code
|
|
||||||
unload - unloading code
|
|
||||||
main - Ran as a process and has normal behavior (used for checking network like things)
|
|
||||||
arch - architecture difined in bootloader (EX: cct, oc, ac, cc, ccpc, or all)
|
|
||||||
description - discription
|
|
||||||
author - author of driver
|
|
||||||
```
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# tty driver
|
|
||||||
---
|
|
||||||
|
|
||||||
tty (Teletypewriter) is a driver class made for basic text output (ASCII only) used for primitive ui.
|
|
||||||
|
|
||||||
```
|
|
||||||
API Signature
|
|
||||||
String: address
|
|
||||||
Address unique to the screen
|
|
||||||
|
|
||||||
print(String: text):Nil
|
|
||||||
Prints text to the screen with a following \n
|
|
||||||
|
|
||||||
printInline(String: text):Nil
|
|
||||||
Prints text to the screen without following \n
|
|
||||||
|
|
||||||
clear():Nil
|
|
||||||
Clears screen sets x,y of cursor to 0,0
|
|
||||||
|
|
||||||
setBackgroundColor(Number: index):Nil
|
|
||||||
Sets background color to index of pallete
|
|
||||||
|
|
||||||
getBackgroundColor():Number
|
|
||||||
Returns current background index of screen
|
|
||||||
|
|
||||||
setForegroundColor(Number: index):Nil
|
|
||||||
Sets foreground color to index of pallete
|
|
||||||
|
|
||||||
getForegroundColor():Number
|
|
||||||
Returns current foreground index of screen
|
|
||||||
|
|
||||||
setCursorPos(Number: x, Number: y):Nil
|
|
||||||
Sets x,y position of cursor
|
|
||||||
|
|
||||||
getCursorPos():Number, Number
|
|
||||||
Gets x,y position of cursor
|
|
||||||
```
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
01 SIGHUP Terminate Hang up controlling terminal or Yes
|
|
||||||
process
|
|
||||||
02 SIGINT Terminate Interrupt from keyboard, Control-C Yes
|
|
||||||
03 SIGQUIT Dump Quit from keyboard, Control-\ Yes
|
|
||||||
04 SIGILL Dump Illegal instruction Yes
|
|
||||||
05 SIGTRAP Dump Breakpoint for debugging No
|
|
||||||
06 SIGABRT Dump Abnormal termination Yes
|
|
||||||
06 SIGIOT Dump Equivalent to SIGABRT No
|
|
||||||
07 SIGBUS Dump Bus error No
|
|
||||||
08 SIGFPE Dump Floating-point exception Yes
|
|
||||||
09 SIGKILL Terminate Forced-process termination Yes
|
|
||||||
10 SIGUSR1 Terminate Available to processes Yes
|
|
||||||
11 SIGSEGV Dump Invalid memory reference Yes
|
|
||||||
12 SIGUSR2 Terminate Available to processes Yes
|
|
||||||
13 SIGPIPE Terminate Write to pipe with no readers Yes
|
|
||||||
14 SIGALRM Terminate Real-timer clock Yes
|
|
||||||
15 SIGTERM Terminate Process termination Yes
|
|
||||||
16 SIGSTKFLT Terminate Coprocessor stack error No
|
|
||||||
17 SIGCHLD Ignore Child process stopped or terminated Yes
|
|
||||||
or got a signal if traced
|
|
||||||
18 SIGCONT Continue Resume execution, if stopped Yes
|
|
||||||
19 SIGSTOP Stop Stop process execution, Ctrl-Z Yes
|
|
||||||
20 SIGTSTP Stop Stop process issued from tty Yes
|
|
||||||
21 SIGTTIN Stop Background process requires input Yes
|
|
||||||
22 SIGTTOU Stop Background process requires output Yes
|
|
||||||
23 SIGURG Ignore Urgent condition on socket No
|
|
||||||
24 SIGXCPU Dump CPU time limit exceeded No
|
|
||||||
25 SIGXFSZ Dump File size limit exceeded No
|
|
||||||
26 SIGVTALRM Terminate Virtual timer clock No
|
|
||||||
27 SIGPROF Terminate Profile timer clock No
|
|
||||||
28 SIGWINCH Ignore Window resizing No
|
|
||||||
29 SIGIO Terminate I/O now possible No
|
|
||||||
29 SIGPOLL Terminate Equivalent to SIGIO No
|
|
||||||
30 SIGPWR Terminate Power supply failure No
|
|
||||||
31 SIGSYS Dump Bad system call No
|
|
||||||
32 SIGUNUSED Dump Equivalent to SIGSYS No
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
---@diagnostic disable: undefined-global
|
||||||
-- unpack_tar.lua
|
-- unpack_tar.lua
|
||||||
-- Fully working TAR unpacker for ComputerCraft
|
-- Fully working TAR unpacker for ComputerCraft
|
||||||
-- Handles Windows Explorer TAR bug (duplicated path segments)
|
-- Handles Windows Explorer TAR bug (duplicated path segments)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
---@diagnostic disable: undefined-global
|
||||||
shell.run("unpack Build.tar /")
|
shell.run("unpack Build.tar /")
|
||||||
shell.run("rm $")
|
shell.run("rm $")
|
||||||
shell.run("cp Build $")
|
shell.run("cp Build $")
|
||||||
|
|||||||
Reference in New Issue
Block a user