
Show HN: Luakernel – Lua + SQLite + musl libc running on x86 - ers35
https://github.com/ers35/luakernel
======
nl
Since there is nothing obvious on the page: This is Lua+SQLite running on
_bare metal_ x86.

Lots of questions: does it actually have any performance benefits? A network
stack? How do the mechanics of getting/editing files work?

~~~
hwh
The codebase is so small that it's quite easy to take a look to answer the
questions:

* no networking at all

* performance - doing what?

* file primitives are implemented purely in Lua, and what is currently there resembles a pre-initialized ramfs. Closing a file is a NOP, the concept of numerical file descriptors is not fully implemented yet. So - no block devices yet.

* aside from file primitives, you have lua coroutines as the core of the scheduling, inb()/outb() (bytewise port I/O), and putpixel/clearscreen in the API implemented in C, as well as basic keyboard handling (using inb/outb wrappers) and graphics primitives (using putpixel/clearscreen) implemented in Lua.

I suggest to take a quick peek at luakernel.c and luakernel.lua in the
codebase.

~~~
justincormack
If you want Lua running on bare metal with a network stack you can use the
rump kernel[1].

[1] [http://rumpkernel.org/](http://rumpkernel.org/)

------
metafex
It would be very interesting if this could be combined with snabbswitch for
some truly awesome bare-metal lua networking.

~~~
easytiger
I've never seen snabbswitch before, are there any lua extensions to get it to
emulate tcp/ip stack and present the data stream to your lua code??

~~~
metafex
It basically talks to certain network-cards directly, bypassing the TCP/IP
stack. AFAIK it presents raw ethernet packets to the lua code which have to be
parsed by the application (i don't know exactly if there isn't some code
present in the repo to deal with sockets and such directly). The repo:
[https://github.com/SnabbCo/snabbswitch](https://github.com/SnabbCo/snabbswitch)
Under src/apps there are some examples.

~~~
srcmap
is it a .ko or an user space app?

~~~
justincormack
Userspace, it mmaps that PCI space itself.

------
kator
Downloaded the iso and ran under a vm but it crashes as soon as I try any
command.

I'm curious what's the easiest way to test this?

[1]
[https://github.com/ers35/luakernel/blob/master/bin/luakernel...](https://github.com/ers35/luakernel/blob/master/bin/luakernel.iso)

~~~
cdawzrd
Try running it under qemu[1] or bochs[2]. A "virtual machine" software such as
VMWare or Virtualbox is not the same as a low-level "bare metal" CPU emulator
such as the two I suggested. The latter programs make assumptions about how
the guest OS will behave that probably aren't valid for this project.

I suggest starting with bochs since this project has a bochsrc.txt in the git
root that will be automatically picked up if you just run "bochs" in that
directory.

[1] [http://wiki.qemu.org/Main_Page](http://wiki.qemu.org/Main_Page)

[2] [http://bochs.sourceforge.net/](http://bochs.sourceforge.net/)

------
allan_s
Pretty interesting, just a pity he didn't specified an actual license, as
"disclaims all copyright" has no legal value and even if it had, it would
certainly mean different things from one country to an other (for example in
France you can't, even yourself, put something you've produced in the public
domain as you can't cede your paternity 'right')

~~~
ers35
I took inspiration from SQLite:
[https://www.sqlite.org/copyright.html](https://www.sqlite.org/copyright.html)
[https://github.com/ers35/luakernel/blob/master/dep/sqlite3/s...](https://github.com/ers35/luakernel/blob/master/dep/sqlite3/sqlite3.h#L4)

I agree that the licensing terms need clarification.

~~~
bch
Richard Hipp went on to say he wishes he didn't use public domain, because of
its ambiguity.

see:
[https://web.archive.org/web/20120510151444/http://methodlogi...](https://web.archive.org/web/20120510151444/http://methodlogic.net/BSDFossil.html)

------
marktangotango
What does this need to be useful for real work? Ie serve html? A network
stack, file system, process mgmt?

