Compare commits

..

No commits in common. "master" and "windows" have entirely different histories.

23 changed files with 98 additions and 4254 deletions

View File

@ -1,11 +1,11 @@
# LuPI2 Makefile
# Default compiler settings.
PREFIX?=powerpc-linux-musl
PREFIX?=x86_64-linux-musl
CC = $(PREFIX)-gcc
CFLAGS?=-O2 -std=c99 -fdata-sections -ffunction-sections -pthread
LDFLAGS+= -O2 -Wl,--gc-sections -static -Ldependencies/lib-$(PREFIX) -pthread
CFLAGS?=-O2 -std=c99 -DLUA_COMPAT_MODULE -fdata-sections -ffunction-sections
LDFLAGS+= -O2 -Wl,--gc-sections -static -Ldependencies/lib-$(PREFIX)
# Project specific stuff
BUILD = bin/
@ -35,8 +35,6 @@ OUTNAME = lupi
debug: CFLAGS+= -g -DLOGGING -DDEBUG
debug: build
####
winexe: $(BUILD)$(OUTNAME)
cp $(BUILD)$(OUTNAME) $(BUILD)$(OUTNAME).exe
@ -50,55 +48,6 @@ win-build: build winexe
win-debug: LIBS+= -lws2_32 -lgdi32
win-debug: debug winexe
####
dependencies/v86:
cd dependencies; git clone https://github.com/magik6k/v86.git
dependencies/v86/build/libv86.js: dependencies/v86
cd dependencies/v86 && wget -P closure-compiler http://dl.google.com/closure-compiler/compiler-latest.zip
cd dependencies/v86 && unzip -d closure-compiler closure-compiler/compiler-latest.zip compiler.jar
cd dependencies/v86 && make build/libv86.js
$(BUILD)web: dependencies/v86/build/libv86.js
rm -rf bin/web; mkdir -p bin/web
web: iso bin/web
####
ISOKERNEL=linux-5.12.1
dependencies/$(ISOKERNEL).tar.xz:
cd dependencies && wget https://cdn.kernel.org/pub/linux/kernel/v5.x/$(ISOKERNEL).tar.xz
dependencies/$(ISOKERNEL)/arch/x86/boot/bzImage: $(BUILD)lupi.cpio dependencies/$(ISOKERNEL).tar.xz
rm -rf dependencies/$(ISOKERNEL)/
cd dependencies && tar xf $(ISOKERNEL).tar.xz
cp src/iso/linux.config dependencies/$(ISOKERNEL)/.config
cd dependencies/$(ISOKERNEL)/ && make -j8
$(BUILD)lupi.cpio: $(BUILDDIRECTORIES) $(BUILD)$(OUTNAME) build
rm -rf $(BUILD)iso.init; mkdir -p $(BUILD)iso.init
mkdir -p bin/iso.init/sbin bin/iso.init/proc bin/iso.init/sys bin/iso.init/dev bin/iso.init/tmp
cp bin/lupi bin/iso.init/sbin/init
(cd bin/iso.init; find . | fakeroot cpio -o -H newc) > $@
$(BUILD)lupi.iso: dependencies/$(ISOKERNEL)/arch/x86/boot/bzImage
rm -rf bin/iso.dir; mkdir -p bin/iso.dir bin/iso.dir/boot
cp $(BUILD)lupi.cpio bin/iso.dir/boot/lupi.img
cp dependencies/$(ISOKERNEL)/arch/x86/boot/bzImage bin/iso.dir/boot/vmlinuz
cp src/iso/isolinux.cfg bin/iso.dir/isolinux.cfg
mkdir -p bin/iso.dir/syslinux bin/iso.dir/sbin
cp bin/lupi bin/iso.dir/sbin/init
cp /usr/lib/syslinux/bios/{isolinux.bin,ldlinux.c32,isohdpfx.bin} bin/iso.dir/syslinux/
mkisofs -o bin/lupi.iso -b syslinux/isolinux.bin -c syslinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table bin/iso.dir
iso: PREFIX?=i486-linux-musl
iso: build $(BUILD)lupi.iso
####
$(BUILDDIRECTORIES):
mkdir -p $@
@ -132,4 +81,4 @@ smallclean:
# Other
.PHONY: web iso debug clean cleanresourcues resources build smallclean all
.PHONY: debug clean cleanresourcues resources build smallclean all

View File

@ -1,14 +1,16 @@
# LuPPC
Lua-based operating system, based on [LuPI2](https://github.com/Starchasers/LuPI2/), with a focus on PowerPC based Macintosh machines and an aim to support more OpenComputers-style components and mirror OpenComputers behavior more closely where practical.
# LuPI2
Second attempt at Lua based operating system, primarily aimed at RaspberryPi, but with ambition to support other boards as well. The main motivation is
fact that GNU/Linux + python solution isn't allays the best for people that haven't been programming ever, and Lua in one of the simplest, most
intuitive languages. It has only 6 types, very simple syntax, yet supports many advanced mechanisms.
Build
-----
1. Clone this repository
2. Get musl cross compiler (like arm-linux-musleabihf or powerpc-linux-musl), simplest way is to use [musl-cross-make](https://github.com/richfelker/musl-cross-make)
2. Get musl cross compiler(like arm-linux-musleabihf), simplest way is to use [musl-cross](https://github.com/GregorR/musl-cross)
3. Get `xxd` utility (usually packaged with vim)
4. Build dependencies using scripts/dependencies.sh script for your platform(s)
5. Execute `make build`
6. You will need to put some OS to `root` directory where you run the binary. For now you can get PsychOS2 from the [PsychOS build server](https://oc.shadowkat.net/psychos/psychos.cpio)
6. You will need to put some OS to `root` directory where you run the binary. For now you can get plan9k at https://cloud.magik6k.net/index.php/s/7jPRAU037dzt8Ga/download
In case of problems poke me/someone at #lupi on Freenode

View File

@ -8,12 +8,10 @@
void logn(const char *message);
void logi(int message);
void logm(const char *message);
void logt(const char *message);
#else
#define logn(m)
#define logi(m)
#define logm(m)
#define logt(m)
#endif
#define pushstuple(state, name, value) lua_pushstring((state), (name)); lua_pushstring((state), (value)); lua_settable((state), -3)
@ -34,11 +32,7 @@ int event_pull(int timeout);
#ifdef _WIN32
void winapigpu_init(lua_State* L);
#define WIN32
#include <event2/event.h>
#include <event2/event_struct.h>
void handleWinevent(evutil_socket_t fd, short what, void *eventc);
#undef WIN32
int winapigpu_events();
#endif
#endif

View File

@ -38,10 +38,6 @@ case "$1" in
TOOL=i686-w64-mingw32
OUT=$TOOL
;;
powerpc )
TOOL=powerpc-linux-musl
OUT=$TOOL
;;
*) echo "Invalid target!" ; exit 1
;;
esac

View File

@ -6,29 +6,19 @@
#include <unistd.h>
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#define WIN32
#endif
#ifdef WIN32
#define LOCAL_SOCKETPAIR_AF AF_INET
#else
#define LOCAL_SOCKETPAIR_AF AF_UNIX
#endif
#include <event2/event.h>
#include <event2/event_struct.h>
struct event_base *base;
struct event stdinEvent;
int nevt = 0;
static void handleStdin(evutil_socket_t fd, short what, void *eventc) {
static void handleStdin(evutil_socket_t fd, short what, void *ptr) {
char buf;
if(what != EV_READ) return;
int r = read(fd, &buf, 1); /* TODO: Wide chars? */
if(r > 0) {
lua_State* L = getL();
@ -49,42 +39,30 @@ static void handleStdin(evutil_socket_t fd, short what, void *eventc) {
lua_pushstring(L, "root");
lua_call(L, 5, 0);
*((int*) eventc) += 2;
nevt += 2;
}
}
#ifdef _WIN32
extern evutil_socket_t winInputPipe[2]; //TODO: make it nicer
struct event winEvent;
#endif
void event_prepare() {
struct event_config* cfg = event_config_new();
event_config_set_flag(cfg, EVENT_BASE_FLAG_NO_CACHE_TIME);
base = event_base_new_with_config(cfg);
base = event_base_new_with_config(cfg);
evutil_make_socket_nonblocking(STDIN_FILENO);
event_assign(&stdinEvent, base, STDIN_FILENO, EV_READ, handleStdin, &nevt);
#ifdef _WIN32
evutil_socketpair(LOCAL_SOCKETPAIR_AF, SOCK_STREAM, 0, winInputPipe);
evutil_make_socket_nonblocking(winInputPipe[0]);
event_assign(&winEvent, base, winInputPipe[0], EV_READ, handleWinevent, &nevt);
#endif
event_assign(&stdinEvent, base, STDIN_FILENO, EV_READ, handleStdin, NULL);
}
static void add_events(struct timeval* timeout) {
#ifndef _WIN32
event_add(&stdinEvent, timeout);
#endif
#ifdef _WIN32
event_add(&winEvent, timeout);
#endif
}
int event_pull(int _timeout) {
int n = 0;
#ifdef _WIN32
n = winapigpu_events();
if(n > 0) return n;
#endif
if(_timeout > 0) { /* wait max this much time for event */
struct timeval timeout = {_timeout / 1000, (_timeout % 1000) * 1000};

View File

@ -1,45 +0,0 @@
#include "lupi.h"
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#ifdef _WIN32
#define WIN32
#include <event2/event.h>
#include <event2/event_struct.h>
evutil_socket_t winInputPipe[2] = {0,0};
void pokeWinEvt(char ch) {
send(winInputPipe[1], &ch, 1, 0);
}
void handleWinevent(evutil_socket_t fd, short what, void *eventc) {
if(what != EV_READ) return;
char buf;
int r = recv(fd, &buf, 1, 0); /* TODO: Wide chars? */
if(r > 0) {
lua_State* L = getL();
lua_getglobal(L, "pushEvent");
lua_pushstring(L, "key_down");
lua_pushstring(L, "TODO:SetThisUuid");/* Also in textgpu.lua */
lua_pushnumber(L, buf);
lua_pushnumber(L, -1);
lua_pushstring(L, "root");
lua_call(L, 5, 0);
lua_getglobal(L, "pushEvent");
lua_pushstring(L, "key_up");
lua_pushstring(L, "TODO:SetThisUuid");
lua_pushnumber(L, buf);
lua_pushnumber(L, -1);
lua_pushstring(L, "root");
lua_call(L, 5, 0);
*((int*) eventc) += 2;
}
}
#endif

View File

@ -437,47 +437,27 @@ static int l_fb_ready (lua_State *L) {
}
void fb_start(lua_State *L) {
struct luaL_Reg fblib[] = {
#ifndef _WIN32
{"setPalette", l_set_palette},
{"getWidth", l_get_width},
{"getHeight", l_get_height},
{"put", l_fbput},
{"copy", l_fbcopy},
{"fill", l_fbfill},
{"getBackground", l_fb_getbg},
{"getForeground", l_fb_getfg},
{"get", l_fb_get},
{"getfg", l_fb_getfg},
{"getbg", l_fb_getbg},
{"getNearest", l_get_nearest},
#endif
{"isReady", l_fb_ready},
{NULL, NULL}
};
luaL_openlib(L, "framebuffer", fblib, 0);
#ifndef _WIN32
fb_file = open("/dev/fb0", O_RDWR);
if (fb_file == -1) {
printf("Error: cannot open framebuffer device");
exit(1);
return;
}
if (ioctl(fb_file, FBIOGET_FSCREENINFO, &fb_finfo) == -1) {
printf("Error reading fixed information");
close(fb_file);
exit(1);
return;
}
if (ioctl(fb_file, FBIOGET_VSCREENINFO, &fb_vinfo) == -1) {
printf("Error reading variable information");
close(fb_file);
exit(1);
return;
}
fb_vinfo.bits_per_pixel = 32;
fb_vinfo.bits_per_pixel = 16;
if (fb_rot == 1 || fb_rot == 3) {
fb_cw = fb_vinfo.yres / 8;
fb_ch = fb_vinfo.xres / 16;
@ -489,7 +469,7 @@ void fb_start(lua_State *L) {
fb_vinfo.bits_per_pixel = 32;
if (ioctl(fb_file, FBIOPUT_VSCREENINFO, &fb_vinfo) == -1) {
printf("Error setting 32 or 16BPP mode");
close(fb_file);
exit(1);
return;
}
}
@ -503,7 +483,7 @@ void fb_start(lua_State *L) {
fb_ptr = (char *)mmap(0, fb_vinfo.xres * fb_vinfo.yres * fb_bypp, PROT_READ | PROT_WRITE, MAP_SHARED, fb_file, 0);
if ((intptr_t)fb_ptr == -1) {
printf("Failed to map framebuffer device to memory");
close(fb_file);
exit(1);
return;
}
@ -513,4 +493,23 @@ void fb_start(lua_State *L) {
fb_ready = 1;
#endif
struct luaL_Reg fblib[] = {
#ifndef _WIN32
{"setPalette", l_set_palette},
{"getWidth", l_get_width},
{"getHeight", l_get_height},
{"put", l_fbput},
{"copy", l_fbcopy},
{"fill", l_fbfill},
{"getBackground", l_fb_getbg},
{"getForeground", l_fb_getfg},
{"get", l_fb_get},
{"getNearest", l_get_nearest},
#endif
{"isReady", l_fb_ready},
{NULL, NULL}
};
luaL_openlib(L, "framebuffer", fblib, 0);
}

View File

@ -4,22 +4,15 @@
#include <sys/mount.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/statvfs.h>
#include <sys/mount.h>
void lupi_init() {
if(getpid() == 1) {
mount(NULL, "/sys", "sysfs", 0, NULL);
mount(NULL, "/proc", "procfs", 0, NULL);
mount(NULL, "/tmp", "tmpfs", 0, NULL);
}
struct statvfs fsstat;
statvfs("/", &fsstat);
printf("Filesystem / RO status: %X\n",fsstat.f_flag & MS_RDONLY);
}
#else
void lupi_init() {
}
#endif
#endif

View File

@ -13,7 +13,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <linux/reboot.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
@ -26,8 +25,6 @@
#define KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
long logStart = -1;
/* Enable in lupi.h */
#ifdef LOGGING
void logn(const char *message) {
@ -72,17 +69,6 @@ void logm(const char *message) {
}
}
void logt(const char *message) {
struct timeval tp;
gettimeofday(&tp, NULL);
logm("[");
logi(tp.tv_sec - logStart);
logm("+");
logi(tp.tv_usec);
logm("]");
logm(message);
}
static int l_log (lua_State *L) {
const char* t = lua_tostring(L, 1);
logn(t);
@ -93,7 +79,6 @@ static int l_log (lua_State *L) {
#define logn(m)
#define logi(m)
#define logm(m)
#define logt(m)
static int l_log (lua_State *L) {
return 0;
}
@ -101,8 +86,7 @@ static int l_log (lua_State *L) {
static int l_sleep (lua_State *L) {
unsigned int t = lua_tonumber(L, 1);
struct timespec st = {.tv_sec = t / 1000000, .tv_nsec = (t % 1000000) * 1000};
nanosleep(&st, NULL);
usleep(t);
return 0;
}
@ -152,7 +136,7 @@ static int l_fs_spaceUsed (lua_State *L) {
#ifndef _WIN32
struct statvfs s;
if( statvfs(fname, &s) != -1 ) {
lua_pushnumber(L, s.f_bsize * (s.f_blocks - s.f_bfree));
lua_pushnumber(L, s.f_bsize * s.f_bfree);
} else {
lua_pushnumber(L, -1);
}
@ -378,18 +362,6 @@ static int l_uptime (lua_State *L) { /* Return ms */
return 1;
}
static int l_shutdown(lua_State *L) {
int shutdownmode = lua_toboolean(L, 1);
sync();
printf("%i", shutdownmode);
int rebootcmd = LINUX_REBOOT_CMD_POWER_OFF;
if (shutdownmode == 1) {
rebootcmd = LINUX_REBOOT_CMD_RESTART;
}
reboot(rebootcmd);
exit(0);
}
static int l_totalMemory (lua_State *L) {
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
MEMORYSTATUS status;
@ -478,10 +450,6 @@ static int l_debug (lua_State *L) {
void luanative_start(lua_State *L) {
struct timeval tp;
gettimeofday(&tp, NULL);
logStart = tp.tv_sec;
struct luaL_Reg nativelib[] = {
{"sleep", l_sleep},
{"log", l_log},
@ -505,7 +473,6 @@ void luanative_start(lua_State *L) {
{"towupper", l_towupper},
{"beep", l_beep},
{"uptime", l_uptime},
{"shutdown", l_shutdown},
{"totalMemory", l_totalMemory},
{"freeMemory", l_freeMemory},
{"pull", l_pull},

View File

@ -5,8 +5,6 @@
#include <lualib.h>
#include <lauxlib.h>
#include <windows.h>
#include <pthread.h>
#include <time.h>
#define BYPP 4
#define RES_X 800
@ -23,7 +21,6 @@
#define uchar unsigned char
HWND hwnd;
uchar *screenbb = NULL;
HBITMAP screenbmap = NULL;
char *colbuf = 0;
@ -72,11 +69,12 @@ static inline int win_draw_32(int x, int y, int bg, int fg, int chr, int cwd) {
}
}
void pokeWinEvt(char ch);
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_PAINT: {
logn("win: PAINT");
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
screenbmap = CreateBitmap(RES_X, RES_Y, 1, BYPP * 8, (void*) screenbb);
@ -88,21 +86,18 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
EndPaint(hwnd, &ps);
}
break;
case WM_CHAR:
case WM_UNICHAR:
//case WM_KEYUP:
case WM_KEYDOWN: {
logi(wParam);
logn("");
pokeWinEvt(wParam);
break;
}
case WM_CREATE:
logn("win: Create");
screenbb = (uchar*) calloc(RES_X * RES_Y, BYPP);
//for(int i = 0; i < RES_X * RES_Y * BYPP; i++) screenbb[i] = (uchar) rand();
win_draw_32(0, 0, 0, 0xFFFFFF, 'H', 1);
win_draw_32(1, 0, 0, 0xFFFFFF, 'e', 1);
win_draw_32(2, 0, 0, 0xFFFFFF, 'l', 1);
win_draw_32(3, 0, 0, 0xFFFFFF, 'l', 1);
win_draw_32(4 , 0, 0, 0xFFFFFF, 'o', 1);
colbuf = (char*) malloc(2 * CHARSW * CHARSH);
chrbuf = (ushort*) malloc(2 * CHARSW * CHARSH);
colbuf = (char *)malloc(2 * CHARSW * CHARSH);
chrbuf = (ushort *)malloc(2 * CHARSW * CHARSH);
break;
case WM_CLOSE:
@ -118,11 +113,13 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
return 0;
}
static int win_draw(int x, int y, int bg, int fg, int chr);
void* winapigpu_events(void* ign) {
static int l_open(lua_State *L) {
logn("win: INIT");
WNDCLASSEX wc;
HWND hwnd;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
@ -138,7 +135,9 @@ void* winapigpu_events(void* ign) {
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) {
return 0;
lua_pushboolean(L, 0);
lua_pushstring(L, "Window registration failed");
return 2;
}
hwnd = CreateWindowEx(
@ -150,7 +149,9 @@ void* winapigpu_events(void* ign) {
NULL, NULL, GetModuleHandle(NULL), NULL);
if(hwnd == NULL) {
return 0;
lua_pushboolean(L, 0);
lua_pushstring(L, "Window creation failed");
return 2;
}
ShowWindow(hwnd, SW_SHOW);
@ -158,27 +159,6 @@ void* winapigpu_events(void* ign) {
InvalidateRect(hwnd, NULL, TRUE);
win_draw(0,0,0,0xFFFFFF,'H');
MSG Msg;
while(GetMessage(&Msg, NULL, 0, 0) > 0) {
//TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
logn("winapi quit!!");
return NULL;
}
static int l_open(lua_State *L) {
pthread_t eventThread;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 0x800000);
pthread_create(&eventThread, &attr, winapigpu_events, NULL);
pthread_attr_destroy(&attr);
struct timespec st = {.tv_sec = 0, .tv_nsec = 1000000};
while(!screenbb) nanosleep(&st, NULL);
lua_pushboolean(L, 1);
return 1;
}
@ -243,9 +223,7 @@ static int l_put (lua_State *L) {
int bg = lua_tonumber(L, 3);
int fg = lua_tonumber(L, 4);
int chr = lua_tonumber(L, 5);
win_draw(x, y, bg, fg, chr);
InvalidateRect(hwnd, NULL, FALSE);
return 0;
return win_draw(x, y, bg, fg, chr);
}
static int l_get_nearest (lua_State *L) {
@ -304,7 +282,6 @@ static int l_copy (lua_State *L) {
free(tmpcol);
free(tmpchr);
InvalidateRect(hwnd, NULL, FALSE);
}
static int l_fill (lua_State *L) {
@ -321,7 +298,6 @@ static int l_fill (lua_State *L) {
win_draw(j, i, bg, fg, chr);
}
}
InvalidateRect(hwnd, NULL, FALSE);
return 0;
}
@ -339,7 +315,6 @@ static int l_winfill (lua_State *L) {
win_draw(j, i, bg, fg, chr);
}
}
InvalidateRect(hwnd, NULL, FALSE);
return 0;
}
@ -407,4 +382,13 @@ void winapigpu_init(lua_State* L) {
luaL_openlib(L, "winapigpu", winlib, 0);
}
int winapigpu_events() {
MSG Msg;
while(GetMessage(&Msg, NULL, 0, 0) > 0) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return 0;
}
#endif

View File

@ -1,6 +0,0 @@
prompt 0
default 1
LABEL 1
LINUX boot/vmlinuz
INITRD boot/lupi.img

File diff suppressed because it is too large Load Diff

View File

@ -46,9 +46,6 @@ function boot.boot()
bsod(reason)
else
local crash = false
if native.debug then
native.sleep(500000)
end
xpcall(f, function(e)
local trace = {}

View File

@ -50,7 +50,7 @@ function api.register(address, ctype, proxy, doc)
end
components[address] = {address = address, type = ctype, doc = doc or {}}
components[address].rawproxy = proxy
components[address].proxy = {address = address, type = ctype, slot = -1}
components[address].proxy = {}
for k,v in pairs(proxy) do
if type(v) == "function" then
components[address].proxy[k] = setmetatable({name=k,address=address}, componentCallback)

View File

@ -101,14 +101,14 @@ function computer.signalTransformers.key_down(s, a, ascii, key, user)
if key ~= -1 then
return s, a, ascii, key, user
end
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user
return s, a, asciitr[ascii] or ascii, keymap[ascii] or key, user
end
function computer.signalTransformers.key_up(s, a, ascii, key, user)
if key ~= -1 then
return s, a, ascii, key, user
end
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user
return s, a, asciitr[ascii] or ascii, keymap[ascii] or key, user
end
-----
@ -166,7 +166,7 @@ function api.totalMemory()
return native.totalMemory()
end
function api.shutdown(reboot)
function api.shutdown()
--TODO: Longjmp to init somehow?
print("Running shutdown hooks")
for k, hook in ipairs(deadhooks) do
@ -178,8 +178,7 @@ function api.shutdown(reboot)
end
print("Hooks executed: " .. #deadhooks)
native.shutdown(reboot)
os.exit(0)
end
return computer
return computer

View File

@ -106,7 +106,7 @@ function fbgpu.start()
function gpu.get(x, y)
checkArg(1, x, "number")
checkArg(2, y, "number")
return utf8.char(fb.get(x-1, y-1)), mapping[fb.getfg(x-1, y-1)], mapping[fb.getbg(x-1, y-1)]
return utf8.char(fb.get(x-1, y-1))
end
function gpu.set(x, y, value, vertical)
checkArg(1, x, "number")
@ -117,13 +117,13 @@ function fbgpu.start()
y = math.floor(y)
if not vertical then
local i = 0
value:gsub("([%z\1-\127\194-\244][\128-\191]*)", function(c)
value:gsub(".", function(c)
fb.put(x+i-1, y-1, background, foreground, utf8.codepoint(c))
i = i+1
end)
else
local i = 0
value:gsub("([%z\1-\127\194-\244][\128-\191]*)", function(c)
value:gsub(".", function(c)
fb.put(x-1, y+i-1, background, foreground, utf8.codepoint(c))
i = i+1
end)
@ -147,7 +147,7 @@ function fbgpu.start()
checkArg(3, w, "number")
checkArg(4, h, "number")
checkArg(5, ch, "string")
ch = usub(ch, 1, 1)
ch = ch:sub(1, 1)
fb.fill(x-1, y-1, x+w-2, y+h-2, background, foreground, utf8.codepoint(ch))
return true
end
@ -156,17 +156,11 @@ function fbgpu.start()
gpu.setForeground(0xFFFFFF)
gpu.setBackground(0x000000)
local screenAddr
function gpu.getScreen()
return screenAddr
end
termutils.init()
write("\x1b[?25l") --Disable cursor
modules.component.api.register(nil, "gpu", gpu)
screenAddr = modules.component.api.register(nil, "screen", {getKeyboards = function() return {"TODO:SetThisUuid"} end}) --verry dummy screen, TODO: make it better, kbd uuid also in epoll.c
modules.component.api.register(nil, "screen", {getKeyboards = function() return {"TODO:SetThisUuid"} end}) --verry dummy screen, TODO: make it better, kbd uuid also in epoll.c
modules.component.api.register("TODO:SetThisUuid", "keyboard", {})
deadhooks[#deadhooks + 1] = function()

View File

@ -123,7 +123,7 @@ function filesystem.register(basePath, uuid)
end
function fs.list(path)
checkArg(1, path, "string")
return native.fs_list(realpath(path)) or {} --TODO: Test, check if dirs get / at end
return native.fs_list(realpath(path)) --TODO: Test, check if dirs get / at end
end
function fs.lastModified(path)
checkArg(1, path, "string")
@ -159,4 +159,4 @@ function filesystem.register(basePath, uuid)
return modules.component.api.register(uuid, "filesystem", fs)
end
return filesystem
return filesystem

View File

@ -1,7 +1,6 @@
local gpudetect = {}
local function tryText()
lprint("Trying text-mode gpu")
loadModule("textgpu")
local textgpuAddr, tgfail = modules.textgpu.start()
if not textgpuAddr then
@ -12,7 +11,6 @@ local function tryText()
end
local function tryFb()
lprint("Trying framebuffer-mode gpu")
if framebuffer.isReady() then
loadModule("fbgpu")
modules.fbgpu.start()

View File

@ -107,13 +107,7 @@ function main()
if native.debug and native.platform():match("unix") then
modules.filesystem.register("/", "11111111-1111-1111-1111-111111111111")
end
if native.platform():match("unix") then
modules.computer.tmp = modules.filesystem.register("/tmp/lupi-" .. modules.random.uuid())
else
native.fs_mkdir("tmp")
modules.computer.tmp = modules.filesystem.register("tmp/lupi-" .. modules.random.uuid())
--TODO: cleaning hook or something
end
modules.computer.tmp = modules.filesystem.register("/tmp/lupi-" .. modules.random.uuid())
modules.gpudetect.run()

View File

@ -121,8 +121,8 @@ function textgpu.start()
function gpu.get(x, y)
checkArg(1, x, "number")
checkArg(2, y, "number")
return tbuffer[y]:sub(x,x), mapping[fbuffer[y]:sub(x,x)], mapping[bbuffer[y]:sub(x,x)]
--FIXME: ASAP: Implement
return " "
end
function gpu.set(x, y, value, vertical)
checkArg(1, x, "number")
@ -143,7 +143,7 @@ function textgpu.start()
else
--TODO: Buffers!
write("\x1b[" .. y .. ";" .. x .. "H")
value:gsub("([%z\1-\127\194-\244][\128-\191]*)", function(c)
value:gsub(".", function(c)
write(c .. "\x1b[D\x1b[B")
end)
end

View File

@ -22,10 +22,7 @@ end
local background = 0
local foreground = 0
local usub
function wingpu.start()
usub = modules.sandbox.unicode.sub
local gpu = {}
function gpu.bind() return false, "This is static bound gpu" end
@ -109,13 +106,13 @@ function wingpu.start()
y = math.floor(y)
if not vertical then
local i = 0
value:gsub("([%z\1-\127\194-\244][\128-\191]*)", function(c)
value:gsub(".", function(c)
win.put(x+i-1, y-1, background, foreground, utf8.codepoint(c))
i = i+1
end)
else
local i = 0
value:gsub("([%z\1-\127\194-\244][\128-\191]*)", function(c)
value:gsub(".", function(c)
win.put(x-1, y+i-1, background, foreground, utf8.codepoint(c))
i = i+1
end)
@ -138,7 +135,7 @@ function wingpu.start()
checkArg(3, w, "number")
checkArg(4, h, "number")
checkArg(5, ch, "string")
ch = usub(ch, 1, 1)
ch = ch:sub(1, 1)
win.fill(x-1, y-1, x+w-2, y+h-2, background, foreground, utf8.codepoint(ch))
return true
end
@ -147,11 +144,6 @@ function wingpu.start()
gpu.setForeground(0xFFFFFF)
gpu.setBackground(0x000000)
local screenAddr
function gpu.getScreen()
return screenAddr
end
local s, reason = win.open()
if not s then
@ -159,7 +151,7 @@ function wingpu.start()
end
modules.component.api.register(nil, "gpu", gpu)
screenAddr = modules.component.api.register(nil, "screen", {getKeyboards = function() return {"TODO:SetThisUuid"} end}) --verry dummy screen, TODO: make it better, kbd uuid also in epoll.c
modules.component.api.register(nil, "screen", {getKeyboards = function() return {"TODO:SetThisUuid"} end}) --verry dummy screen, TODO: make it better, kbd uuid also in epoll.c
modules.component.api.register("TODO:SetThisUuid", "keyboard", {})
return s

View File

@ -1,30 +0,0 @@
<!doctype html>
<title>LuPI Web</title>
<script src="libv86.js"></script>
<script>
"use strict";
window.onload = function()
{
var emulator = window.emulator = new V86Starter({
memory_size: 64 * 1024 * 1024,
vga_memory_size: 8 * 1024 * 1024,
screen_container: document.getElementById("screen_container"),
bios: {
url: "seabios.bin",
},
vga_bios: {
url: "bios/vgabios.bin",
},
cdrom: {
url: "lupi.iso",
},
autostart: true,
});
}
</script>
<div id="screen_container">
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
<canvas style="display: none"></canvas>
</div>