Compare commits
No commits in common. "master" and "windows" have entirely different histories.
59
Makefile
59
Makefile
@ -1,11 +1,11 @@
|
|||||||
# LuPI2 Makefile
|
# LuPI2 Makefile
|
||||||
|
|
||||||
# Default compiler settings.
|
# Default compiler settings.
|
||||||
PREFIX?=powerpc-linux-musl
|
PREFIX?=x86_64-linux-musl
|
||||||
|
|
||||||
CC = $(PREFIX)-gcc
|
CC = $(PREFIX)-gcc
|
||||||
CFLAGS?=-O2 -std=c99 -fdata-sections -ffunction-sections -pthread
|
CFLAGS?=-O2 -std=c99 -DLUA_COMPAT_MODULE -fdata-sections -ffunction-sections
|
||||||
LDFLAGS+= -O2 -Wl,--gc-sections -static -Ldependencies/lib-$(PREFIX) -pthread
|
LDFLAGS+= -O2 -Wl,--gc-sections -static -Ldependencies/lib-$(PREFIX)
|
||||||
|
|
||||||
# Project specific stuff
|
# Project specific stuff
|
||||||
BUILD = bin/
|
BUILD = bin/
|
||||||
@ -35,8 +35,6 @@ OUTNAME = lupi
|
|||||||
debug: CFLAGS+= -g -DLOGGING -DDEBUG
|
debug: CFLAGS+= -g -DLOGGING -DDEBUG
|
||||||
debug: build
|
debug: build
|
||||||
|
|
||||||
####
|
|
||||||
|
|
||||||
winexe: $(BUILD)$(OUTNAME)
|
winexe: $(BUILD)$(OUTNAME)
|
||||||
cp $(BUILD)$(OUTNAME) $(BUILD)$(OUTNAME).exe
|
cp $(BUILD)$(OUTNAME) $(BUILD)$(OUTNAME).exe
|
||||||
|
|
||||||
@ -50,55 +48,6 @@ win-build: build winexe
|
|||||||
win-debug: LIBS+= -lws2_32 -lgdi32
|
win-debug: LIBS+= -lws2_32 -lgdi32
|
||||||
win-debug: debug winexe
|
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):
|
$(BUILDDIRECTORIES):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
@ -132,4 +81,4 @@ smallclean:
|
|||||||
|
|
||||||
# Other
|
# Other
|
||||||
|
|
||||||
.PHONY: web iso debug clean cleanresourcues resources build smallclean all
|
.PHONY: debug clean cleanresourcues resources build smallclean all
|
||||||
|
10
README.md
10
README.md
@ -1,14 +1,16 @@
|
|||||||
# LuPPC
|
# LuPI2
|
||||||
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.
|
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
|
Build
|
||||||
-----
|
-----
|
||||||
1. Clone this repository
|
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)
|
3. Get `xxd` utility (usually packaged with vim)
|
||||||
4. Build dependencies using scripts/dependencies.sh script for your platform(s)
|
4. Build dependencies using scripts/dependencies.sh script for your platform(s)
|
||||||
5. Execute `make build`
|
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
|
In case of problems poke me/someone at #lupi on Freenode
|
||||||
|
|
||||||
|
@ -8,12 +8,10 @@
|
|||||||
void logn(const char *message);
|
void logn(const char *message);
|
||||||
void logi(int message);
|
void logi(int message);
|
||||||
void logm(const char *message);
|
void logm(const char *message);
|
||||||
void logt(const char *message);
|
|
||||||
#else
|
#else
|
||||||
#define logn(m)
|
#define logn(m)
|
||||||
#define logi(m)
|
#define logi(m)
|
||||||
#define logm(m)
|
#define logm(m)
|
||||||
#define logt(m)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define pushstuple(state, name, value) lua_pushstring((state), (name)); lua_pushstring((state), (value)); lua_settable((state), -3)
|
#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
|
#ifdef _WIN32
|
||||||
void winapigpu_init(lua_State* L);
|
void winapigpu_init(lua_State* L);
|
||||||
#define WIN32
|
int winapigpu_events();
|
||||||
#include <event2/event.h>
|
|
||||||
#include <event2/event_struct.h>
|
|
||||||
void handleWinevent(evutil_socket_t fd, short what, void *eventc);
|
|
||||||
#undef WIN32
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,10 +38,6 @@ case "$1" in
|
|||||||
TOOL=i686-w64-mingw32
|
TOOL=i686-w64-mingw32
|
||||||
OUT=$TOOL
|
OUT=$TOOL
|
||||||
;;
|
;;
|
||||||
powerpc )
|
|
||||||
TOOL=powerpc-linux-musl
|
|
||||||
OUT=$TOOL
|
|
||||||
;;
|
|
||||||
*) echo "Invalid target!" ; exit 1
|
*) echo "Invalid target!" ; exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -6,29 +6,19 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#define WIN32
|
#define WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#define LOCAL_SOCKETPAIR_AF AF_INET
|
|
||||||
#else
|
|
||||||
#define LOCAL_SOCKETPAIR_AF AF_UNIX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
#include <event2/event_struct.h>
|
#include <event2/event_struct.h>
|
||||||
|
|
||||||
struct event_base *base;
|
struct event_base *base;
|
||||||
struct event stdinEvent;
|
struct event stdinEvent;
|
||||||
|
|
||||||
int nevt = 0;
|
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;
|
char buf;
|
||||||
|
|
||||||
if(what != EV_READ) return;
|
|
||||||
|
|
||||||
int r = read(fd, &buf, 1); /* TODO: Wide chars? */
|
int r = read(fd, &buf, 1); /* TODO: Wide chars? */
|
||||||
if(r > 0) {
|
if(r > 0) {
|
||||||
lua_State* L = getL();
|
lua_State* L = getL();
|
||||||
@ -49,42 +39,30 @@ static void handleStdin(evutil_socket_t fd, short what, void *eventc) {
|
|||||||
lua_pushstring(L, "root");
|
lua_pushstring(L, "root");
|
||||||
lua_call(L, 5, 0);
|
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() {
|
void event_prepare() {
|
||||||
struct event_config* cfg = event_config_new();
|
struct event_config* cfg = event_config_new();
|
||||||
event_config_set_flag(cfg, EVENT_BASE_FLAG_NO_CACHE_TIME);
|
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);
|
evutil_make_socket_nonblocking(STDIN_FILENO);
|
||||||
event_assign(&stdinEvent, base, STDIN_FILENO, EV_READ, handleStdin, &nevt);
|
event_assign(&stdinEvent, base, STDIN_FILENO, EV_READ, handleStdin, NULL);
|
||||||
|
|
||||||
#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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_events(struct timeval* timeout) {
|
static void add_events(struct timeval* timeout) {
|
||||||
#ifndef _WIN32
|
|
||||||
event_add(&stdinEvent, timeout);
|
event_add(&stdinEvent, timeout);
|
||||||
#endif
|
|
||||||
#ifdef _WIN32
|
|
||||||
event_add(&winEvent, timeout);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int event_pull(int _timeout) {
|
int event_pull(int _timeout) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
#ifdef _WIN32
|
||||||
|
n = winapigpu_events();
|
||||||
|
if(n > 0) return n;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(_timeout > 0) { /* wait max this much time for event */
|
if(_timeout > 0) { /* wait max this much time for event */
|
||||||
struct timeval timeout = {_timeout / 1000, (_timeout % 1000) * 1000};
|
struct timeval timeout = {_timeout / 1000, (_timeout % 1000) * 1000};
|
@ -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
|
|
@ -437,47 +437,27 @@ static int l_fb_ready (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fb_start(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
|
#ifndef _WIN32
|
||||||
fb_file = open("/dev/fb0", O_RDWR);
|
fb_file = open("/dev/fb0", O_RDWR);
|
||||||
if (fb_file == -1) {
|
if (fb_file == -1) {
|
||||||
printf("Error: cannot open framebuffer device");
|
printf("Error: cannot open framebuffer device");
|
||||||
|
exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fb_file, FBIOGET_FSCREENINFO, &fb_finfo) == -1) {
|
if (ioctl(fb_file, FBIOGET_FSCREENINFO, &fb_finfo) == -1) {
|
||||||
printf("Error reading fixed information");
|
printf("Error reading fixed information");
|
||||||
close(fb_file);
|
exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fb_file, FBIOGET_VSCREENINFO, &fb_vinfo) == -1) {
|
if (ioctl(fb_file, FBIOGET_VSCREENINFO, &fb_vinfo) == -1) {
|
||||||
printf("Error reading variable information");
|
printf("Error reading variable information");
|
||||||
close(fb_file);
|
exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fb_vinfo.bits_per_pixel = 32;
|
fb_vinfo.bits_per_pixel = 16;
|
||||||
if (fb_rot == 1 || fb_rot == 3) {
|
if (fb_rot == 1 || fb_rot == 3) {
|
||||||
fb_cw = fb_vinfo.yres / 8;
|
fb_cw = fb_vinfo.yres / 8;
|
||||||
fb_ch = fb_vinfo.xres / 16;
|
fb_ch = fb_vinfo.xres / 16;
|
||||||
@ -489,7 +469,7 @@ void fb_start(lua_State *L) {
|
|||||||
fb_vinfo.bits_per_pixel = 32;
|
fb_vinfo.bits_per_pixel = 32;
|
||||||
if (ioctl(fb_file, FBIOPUT_VSCREENINFO, &fb_vinfo) == -1) {
|
if (ioctl(fb_file, FBIOPUT_VSCREENINFO, &fb_vinfo) == -1) {
|
||||||
printf("Error setting 32 or 16BPP mode");
|
printf("Error setting 32 or 16BPP mode");
|
||||||
close(fb_file);
|
exit(1);
|
||||||
return;
|
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);
|
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) {
|
if ((intptr_t)fb_ptr == -1) {
|
||||||
printf("Failed to map framebuffer device to memory");
|
printf("Failed to map framebuffer device to memory");
|
||||||
close(fb_file);
|
exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,4 +493,23 @@ void fb_start(lua_State *L) {
|
|||||||
fb_ready = 1;
|
fb_ready = 1;
|
||||||
|
|
||||||
#endif
|
#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);
|
||||||
}
|
}
|
@ -4,19 +4,12 @@
|
|||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/statvfs.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
|
|
||||||
void lupi_init() {
|
void lupi_init() {
|
||||||
if(getpid() == 1) {
|
if(getpid() == 1) {
|
||||||
mount(NULL, "/sys", "sysfs", 0, NULL);
|
mount(NULL, "/sys", "sysfs", 0, NULL);
|
||||||
mount(NULL, "/proc", "procfs", 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
|
#else
|
||||||
void lupi_init() {
|
void lupi_init() {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <linux/reboot.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -26,8 +25,6 @@
|
|||||||
|
|
||||||
#define KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
|
#define KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
|
||||||
|
|
||||||
long logStart = -1;
|
|
||||||
|
|
||||||
/* Enable in lupi.h */
|
/* Enable in lupi.h */
|
||||||
#ifdef LOGGING
|
#ifdef LOGGING
|
||||||
void logn(const char *message) {
|
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) {
|
static int l_log (lua_State *L) {
|
||||||
const char* t = lua_tostring(L, 1);
|
const char* t = lua_tostring(L, 1);
|
||||||
logn(t);
|
logn(t);
|
||||||
@ -93,7 +79,6 @@ static int l_log (lua_State *L) {
|
|||||||
#define logn(m)
|
#define logn(m)
|
||||||
#define logi(m)
|
#define logi(m)
|
||||||
#define logm(m)
|
#define logm(m)
|
||||||
#define logt(m)
|
|
||||||
static int l_log (lua_State *L) {
|
static int l_log (lua_State *L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -101,8 +86,7 @@ static int l_log (lua_State *L) {
|
|||||||
|
|
||||||
static int l_sleep (lua_State *L) {
|
static int l_sleep (lua_State *L) {
|
||||||
unsigned int t = lua_tonumber(L, 1);
|
unsigned int t = lua_tonumber(L, 1);
|
||||||
struct timespec st = {.tv_sec = t / 1000000, .tv_nsec = (t % 1000000) * 1000};
|
usleep(t);
|
||||||
nanosleep(&st, NULL);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +136,7 @@ static int l_fs_spaceUsed (lua_State *L) {
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
struct statvfs s;
|
struct statvfs s;
|
||||||
if( statvfs(fname, &s) != -1 ) {
|
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 {
|
} else {
|
||||||
lua_pushnumber(L, -1);
|
lua_pushnumber(L, -1);
|
||||||
}
|
}
|
||||||
@ -378,18 +362,6 @@ static int l_uptime (lua_State *L) { /* Return ms */
|
|||||||
return 1;
|
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) {
|
static int l_totalMemory (lua_State *L) {
|
||||||
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
|
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
|
||||||
MEMORYSTATUS status;
|
MEMORYSTATUS status;
|
||||||
@ -478,10 +450,6 @@ static int l_debug (lua_State *L) {
|
|||||||
|
|
||||||
void luanative_start(lua_State *L) {
|
void luanative_start(lua_State *L) {
|
||||||
|
|
||||||
struct timeval tp;
|
|
||||||
gettimeofday(&tp, NULL);
|
|
||||||
logStart = tp.tv_sec;
|
|
||||||
|
|
||||||
struct luaL_Reg nativelib[] = {
|
struct luaL_Reg nativelib[] = {
|
||||||
{"sleep", l_sleep},
|
{"sleep", l_sleep},
|
||||||
{"log", l_log},
|
{"log", l_log},
|
||||||
@ -505,7 +473,6 @@ void luanative_start(lua_State *L) {
|
|||||||
{"towupper", l_towupper},
|
{"towupper", l_towupper},
|
||||||
{"beep", l_beep},
|
{"beep", l_beep},
|
||||||
{"uptime", l_uptime},
|
{"uptime", l_uptime},
|
||||||
{"shutdown", l_shutdown},
|
|
||||||
{"totalMemory", l_totalMemory},
|
{"totalMemory", l_totalMemory},
|
||||||
{"freeMemory", l_freeMemory},
|
{"freeMemory", l_freeMemory},
|
||||||
{"pull", l_pull},
|
{"pull", l_pull},
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#define BYPP 4
|
#define BYPP 4
|
||||||
#define RES_X 800
|
#define RES_X 800
|
||||||
@ -23,7 +21,6 @@
|
|||||||
|
|
||||||
#define uchar unsigned char
|
#define uchar unsigned char
|
||||||
|
|
||||||
HWND hwnd;
|
|
||||||
uchar *screenbb = NULL;
|
uchar *screenbb = NULL;
|
||||||
HBITMAP screenbmap = NULL;
|
HBITMAP screenbmap = NULL;
|
||||||
char *colbuf = 0;
|
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) {
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
switch(msg) {
|
switch(msg) {
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
|
logn("win: PAINT");
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc = BeginPaint(hwnd, &ps);
|
HDC hdc = BeginPaint(hwnd, &ps);
|
||||||
screenbmap = CreateBitmap(RES_X, RES_Y, 1, BYPP * 8, (void*) screenbb);
|
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);
|
EndPaint(hwnd, &ps);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_CHAR:
|
|
||||||
case WM_UNICHAR:
|
|
||||||
//case WM_KEYUP:
|
|
||||||
case WM_KEYDOWN: {
|
|
||||||
logi(wParam);
|
|
||||||
logn("");
|
|
||||||
pokeWinEvt(wParam);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
logn("win: Create");
|
logn("win: Create");
|
||||||
screenbb = (uchar*) calloc(RES_X * RES_Y, BYPP);
|
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);
|
colbuf = (char *)malloc(2 * CHARSW * CHARSH);
|
||||||
chrbuf = (ushort*) malloc(2 * CHARSW * CHARSH);
|
chrbuf = (ushort *)malloc(2 * CHARSW * CHARSH);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
@ -118,11 +113,13 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
return 0;
|
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");
|
logn("win: INIT");
|
||||||
WNDCLASSEX wc;
|
WNDCLASSEX wc;
|
||||||
|
HWND hwnd;
|
||||||
|
|
||||||
wc.cbSize = sizeof(WNDCLASSEX);
|
wc.cbSize = sizeof(WNDCLASSEX);
|
||||||
wc.style = 0;
|
wc.style = 0;
|
||||||
@ -138,7 +135,9 @@ void* winapigpu_events(void* ign) {
|
|||||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
|
||||||
if(!RegisterClassEx(&wc)) {
|
if(!RegisterClassEx(&wc)) {
|
||||||
return 0;
|
lua_pushboolean(L, 0);
|
||||||
|
lua_pushstring(L, "Window registration failed");
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwnd = CreateWindowEx(
|
hwnd = CreateWindowEx(
|
||||||
@ -150,7 +149,9 @@ void* winapigpu_events(void* ign) {
|
|||||||
NULL, NULL, GetModuleHandle(NULL), NULL);
|
NULL, NULL, GetModuleHandle(NULL), NULL);
|
||||||
|
|
||||||
if(hwnd == NULL) {
|
if(hwnd == NULL) {
|
||||||
return 0;
|
lua_pushboolean(L, 0);
|
||||||
|
lua_pushstring(L, "Window creation failed");
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(hwnd, SW_SHOW);
|
ShowWindow(hwnd, SW_SHOW);
|
||||||
@ -158,27 +159,6 @@ void* winapigpu_events(void* ign) {
|
|||||||
|
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
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);
|
lua_pushboolean(L, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -243,9 +223,7 @@ static int l_put (lua_State *L) {
|
|||||||
int bg = lua_tonumber(L, 3);
|
int bg = lua_tonumber(L, 3);
|
||||||
int fg = lua_tonumber(L, 4);
|
int fg = lua_tonumber(L, 4);
|
||||||
int chr = lua_tonumber(L, 5);
|
int chr = lua_tonumber(L, 5);
|
||||||
win_draw(x, y, bg, fg, chr);
|
return win_draw(x, y, bg, fg, chr);
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_get_nearest (lua_State *L) {
|
static int l_get_nearest (lua_State *L) {
|
||||||
@ -304,7 +282,6 @@ static int l_copy (lua_State *L) {
|
|||||||
|
|
||||||
free(tmpcol);
|
free(tmpcol);
|
||||||
free(tmpchr);
|
free(tmpchr);
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_fill (lua_State *L) {
|
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);
|
win_draw(j, i, bg, fg, chr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +315,6 @@ static int l_winfill (lua_State *L) {
|
|||||||
win_draw(j, i, bg, fg, chr);
|
win_draw(j, i, bg, fg, chr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,4 +382,13 @@ void winapigpu_init(lua_State* L) {
|
|||||||
luaL_openlib(L, "winapigpu", winlib, 0);
|
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
|
#endif
|
@ -1,6 +0,0 @@
|
|||||||
prompt 0
|
|
||||||
default 1
|
|
||||||
|
|
||||||
LABEL 1
|
|
||||||
LINUX boot/vmlinuz
|
|
||||||
INITRD boot/lupi.img
|
|
3911
src/iso/linux.config
3911
src/iso/linux.config
File diff suppressed because it is too large
Load Diff
@ -46,9 +46,6 @@ function boot.boot()
|
|||||||
bsod(reason)
|
bsod(reason)
|
||||||
else
|
else
|
||||||
local crash = false
|
local crash = false
|
||||||
if native.debug then
|
|
||||||
native.sleep(500000)
|
|
||||||
end
|
|
||||||
xpcall(f, function(e)
|
xpcall(f, function(e)
|
||||||
local trace = {}
|
local trace = {}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ function api.register(address, ctype, proxy, doc)
|
|||||||
end
|
end
|
||||||
components[address] = {address = address, type = ctype, doc = doc or {}}
|
components[address] = {address = address, type = ctype, doc = doc or {}}
|
||||||
components[address].rawproxy = proxy
|
components[address].rawproxy = proxy
|
||||||
components[address].proxy = {address = address, type = ctype, slot = -1}
|
components[address].proxy = {}
|
||||||
for k,v in pairs(proxy) do
|
for k,v in pairs(proxy) do
|
||||||
if type(v) == "function" then
|
if type(v) == "function" then
|
||||||
components[address].proxy[k] = setmetatable({name=k,address=address}, componentCallback)
|
components[address].proxy[k] = setmetatable({name=k,address=address}, componentCallback)
|
||||||
|
@ -101,14 +101,14 @@ function computer.signalTransformers.key_down(s, a, ascii, key, user)
|
|||||||
if key ~= -1 then
|
if key ~= -1 then
|
||||||
return s, a, ascii, key, user
|
return s, a, ascii, key, user
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function computer.signalTransformers.key_up(s, a, ascii, key, user)
|
function computer.signalTransformers.key_up(s, a, ascii, key, user)
|
||||||
if key ~= -1 then
|
if key ~= -1 then
|
||||||
return s, a, ascii, key, user
|
return s, a, ascii, key, user
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -166,7 +166,7 @@ function api.totalMemory()
|
|||||||
return native.totalMemory()
|
return native.totalMemory()
|
||||||
end
|
end
|
||||||
|
|
||||||
function api.shutdown(reboot)
|
function api.shutdown()
|
||||||
--TODO: Longjmp to init somehow?
|
--TODO: Longjmp to init somehow?
|
||||||
print("Running shutdown hooks")
|
print("Running shutdown hooks")
|
||||||
for k, hook in ipairs(deadhooks) do
|
for k, hook in ipairs(deadhooks) do
|
||||||
@ -178,7 +178,6 @@ function api.shutdown(reboot)
|
|||||||
end
|
end
|
||||||
print("Hooks executed: " .. #deadhooks)
|
print("Hooks executed: " .. #deadhooks)
|
||||||
|
|
||||||
native.shutdown(reboot)
|
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ function fbgpu.start()
|
|||||||
function gpu.get(x, y)
|
function gpu.get(x, y)
|
||||||
checkArg(1, x, "number")
|
checkArg(1, x, "number")
|
||||||
checkArg(2, y, "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
|
end
|
||||||
function gpu.set(x, y, value, vertical)
|
function gpu.set(x, y, value, vertical)
|
||||||
checkArg(1, x, "number")
|
checkArg(1, x, "number")
|
||||||
@ -117,13 +117,13 @@ function fbgpu.start()
|
|||||||
y = math.floor(y)
|
y = math.floor(y)
|
||||||
if not vertical then
|
if not vertical then
|
||||||
local i = 0
|
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))
|
fb.put(x+i-1, y-1, background, foreground, utf8.codepoint(c))
|
||||||
i = i+1
|
i = i+1
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
local i = 0
|
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))
|
fb.put(x-1, y+i-1, background, foreground, utf8.codepoint(c))
|
||||||
i = i+1
|
i = i+1
|
||||||
end)
|
end)
|
||||||
@ -147,7 +147,7 @@ function fbgpu.start()
|
|||||||
checkArg(3, w, "number")
|
checkArg(3, w, "number")
|
||||||
checkArg(4, h, "number")
|
checkArg(4, h, "number")
|
||||||
checkArg(5, ch, "string")
|
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))
|
fb.fill(x-1, y-1, x+w-2, y+h-2, background, foreground, utf8.codepoint(ch))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -156,17 +156,11 @@ function fbgpu.start()
|
|||||||
gpu.setForeground(0xFFFFFF)
|
gpu.setForeground(0xFFFFFF)
|
||||||
gpu.setBackground(0x000000)
|
gpu.setBackground(0x000000)
|
||||||
|
|
||||||
local screenAddr
|
|
||||||
|
|
||||||
function gpu.getScreen()
|
|
||||||
return screenAddr
|
|
||||||
end
|
|
||||||
|
|
||||||
termutils.init()
|
termutils.init()
|
||||||
write("\x1b[?25l") --Disable cursor
|
write("\x1b[?25l") --Disable cursor
|
||||||
|
|
||||||
modules.component.api.register(nil, "gpu", gpu)
|
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", {})
|
modules.component.api.register("TODO:SetThisUuid", "keyboard", {})
|
||||||
|
|
||||||
deadhooks[#deadhooks + 1] = function()
|
deadhooks[#deadhooks + 1] = function()
|
||||||
|
@ -123,7 +123,7 @@ function filesystem.register(basePath, uuid)
|
|||||||
end
|
end
|
||||||
function fs.list(path)
|
function fs.list(path)
|
||||||
checkArg(1, path, "string")
|
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
|
end
|
||||||
function fs.lastModified(path)
|
function fs.lastModified(path)
|
||||||
checkArg(1, path, "string")
|
checkArg(1, path, "string")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
local gpudetect = {}
|
local gpudetect = {}
|
||||||
|
|
||||||
local function tryText()
|
local function tryText()
|
||||||
lprint("Trying text-mode gpu")
|
|
||||||
loadModule("textgpu")
|
loadModule("textgpu")
|
||||||
local textgpuAddr, tgfail = modules.textgpu.start()
|
local textgpuAddr, tgfail = modules.textgpu.start()
|
||||||
if not textgpuAddr then
|
if not textgpuAddr then
|
||||||
@ -12,7 +11,6 @@ local function tryText()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function tryFb()
|
local function tryFb()
|
||||||
lprint("Trying framebuffer-mode gpu")
|
|
||||||
if framebuffer.isReady() then
|
if framebuffer.isReady() then
|
||||||
loadModule("fbgpu")
|
loadModule("fbgpu")
|
||||||
modules.fbgpu.start()
|
modules.fbgpu.start()
|
||||||
|
@ -107,13 +107,7 @@ function main()
|
|||||||
if native.debug and native.platform():match("unix") then
|
if native.debug and native.platform():match("unix") then
|
||||||
modules.filesystem.register("/", "11111111-1111-1111-1111-111111111111")
|
modules.filesystem.register("/", "11111111-1111-1111-1111-111111111111")
|
||||||
end
|
end
|
||||||
if native.platform():match("unix") then
|
|
||||||
modules.computer.tmp = modules.filesystem.register("/tmp/lupi-" .. modules.random.uuid())
|
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.gpudetect.run()
|
modules.gpudetect.run()
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ function textgpu.start()
|
|||||||
function gpu.get(x, y)
|
function gpu.get(x, y)
|
||||||
checkArg(1, x, "number")
|
checkArg(1, x, "number")
|
||||||
checkArg(2, y, "number")
|
checkArg(2, y, "number")
|
||||||
|
--FIXME: ASAP: Implement
|
||||||
return tbuffer[y]:sub(x,x), mapping[fbuffer[y]:sub(x,x)], mapping[bbuffer[y]:sub(x,x)]
|
return " "
|
||||||
end
|
end
|
||||||
function gpu.set(x, y, value, vertical)
|
function gpu.set(x, y, value, vertical)
|
||||||
checkArg(1, x, "number")
|
checkArg(1, x, "number")
|
||||||
@ -143,7 +143,7 @@ function textgpu.start()
|
|||||||
else
|
else
|
||||||
--TODO: Buffers!
|
--TODO: Buffers!
|
||||||
write("\x1b[" .. y .. ";" .. x .. "H")
|
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")
|
write(c .. "\x1b[D\x1b[B")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -22,10 +22,7 @@ end
|
|||||||
local background = 0
|
local background = 0
|
||||||
local foreground = 0
|
local foreground = 0
|
||||||
|
|
||||||
local usub
|
|
||||||
|
|
||||||
function wingpu.start()
|
function wingpu.start()
|
||||||
usub = modules.sandbox.unicode.sub
|
|
||||||
local gpu = {}
|
local gpu = {}
|
||||||
|
|
||||||
function gpu.bind() return false, "This is static bound gpu" end
|
function gpu.bind() return false, "This is static bound gpu" end
|
||||||
@ -109,13 +106,13 @@ function wingpu.start()
|
|||||||
y = math.floor(y)
|
y = math.floor(y)
|
||||||
if not vertical then
|
if not vertical then
|
||||||
local i = 0
|
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))
|
win.put(x+i-1, y-1, background, foreground, utf8.codepoint(c))
|
||||||
i = i+1
|
i = i+1
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
local i = 0
|
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))
|
win.put(x-1, y+i-1, background, foreground, utf8.codepoint(c))
|
||||||
i = i+1
|
i = i+1
|
||||||
end)
|
end)
|
||||||
@ -138,7 +135,7 @@ function wingpu.start()
|
|||||||
checkArg(3, w, "number")
|
checkArg(3, w, "number")
|
||||||
checkArg(4, h, "number")
|
checkArg(4, h, "number")
|
||||||
checkArg(5, ch, "string")
|
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))
|
win.fill(x-1, y-1, x+w-2, y+h-2, background, foreground, utf8.codepoint(ch))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -147,11 +144,6 @@ function wingpu.start()
|
|||||||
gpu.setForeground(0xFFFFFF)
|
gpu.setForeground(0xFFFFFF)
|
||||||
gpu.setBackground(0x000000)
|
gpu.setBackground(0x000000)
|
||||||
|
|
||||||
local screenAddr
|
|
||||||
|
|
||||||
function gpu.getScreen()
|
|
||||||
return screenAddr
|
|
||||||
end
|
|
||||||
|
|
||||||
local s, reason = win.open()
|
local s, reason = win.open()
|
||||||
if not s then
|
if not s then
|
||||||
@ -159,7 +151,7 @@ function wingpu.start()
|
|||||||
end
|
end
|
||||||
|
|
||||||
modules.component.api.register(nil, "gpu", gpu)
|
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", {})
|
modules.component.api.register("TODO:SetThisUuid", "keyboard", {})
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
@ -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>
|
|
Loading…
Reference in New Issue
Block a user