Jump to content




[WIP] "Omamori" - A hobbyist OS project aka "I put luac in kernel space"

utility computer

22 replies to this topic

#1 KillaVanilla

  • Members
  • 303 posts

Posted 02 May 2014 - 07:19 PM

So I've taken a break from ComputerCraft, and started playing with OS development. This is the result of about two or three week's work and learning; I learned as I coded.

It's still got very, very little functionality, but it at least has a working task-switching system, virtual memory, and standard C library.
I originally planned on writing my own parser and lexer, but have since decided to integrate lua's source code into the kernel.

Suggestions and tips would be appreciated. Any help with the actual code would also be appreciated -- do keep in mind though, this is written in C++, not in Lua.

You can find the Github repository hosting the project here:
https://github.com/Tatantyler/Omamori

The makefile is dependent on a cross-compiler I've set up on my development machine -- see this for details.

Edited by KillaVanilla, 04 June 2014 - 03:52 AM.


#2 TurtleHunter

  • Members
  • 112 posts

Posted 02 May 2014 - 09:33 PM

I tried once to make something like this but lua requires libraries that are difficult to implement from scratch plus you have to implement a file system so io can wok, so i wish you luck and recommend you to look to this tutorial https://github.com/S...perating-System cause it has some of the libraries t¿you need alredy implemented

#3 lieudusty

  • Members
  • 419 posts

Posted 03 May 2014 - 02:20 PM

Amazing project!

Is it going to execute Lua code by compiling it into bytecode that will be run in a Lua VM or will it somehow get converted into native machine code?

Edited by lieudusty, 03 May 2014 - 02:21 PM.


#4 KillaVanilla

  • Members
  • 303 posts

Posted 03 May 2014 - 06:36 PM

View Postlieudusty, on 03 May 2014 - 02:20 PM, said:

Amazing project!

Is it going to execute Lua code by compiling it into bytecode that will be run in a Lua VM or will it somehow get converted into native machine code?
I'm planning on compiling the Lua code to native machine code, though anything could be subject to change at this point.

#5 6677

  • Members
  • 197 posts
  • LocationCambridgeshire, England

Posted 03 May 2014 - 07:02 PM

You should be able to look at some of the existing Lua virtual machine source then, somewhat rarely for a virtual machine it is register based, seems stack based is more popular usually.

#6 viluon

  • Members
  • 183 posts
  • LocationCzech Republic

Posted 04 May 2014 - 02:37 PM

Real OS Dev is the best way to learn how a CC OS should be structured. I'd recommend it to all those noobs trying to make their own resulting in
--#startup file
print("welcome to my (here comes the name) OS!")
sleep(3)
term.clear()
term.setCursorPos(1,1)


#7 KillaVanilla

  • Members
  • 303 posts

Posted 04 June 2014 - 12:51 AM

I've been working on this over the past month.
I've decided to scrap the parser and lexer I had and just integrate the main luac code into my kernel.

Right now, it's working great. Still can't load programs from disk (no hard drive drivers yet, and my PCI driver crashes the kernel when it tries to detect stuff) but at least code execution's working.
Posted Image

The program running here is a simple one-liner:
writeout("hello from lua version ",_VERSION,"!") return 0xC0DE

Where "writeout()" is a function that's basically just "print()". (It bypasses the standard library and prints using the VGA driver's functions directly, though).

Edited by KillaVanilla, 04 June 2014 - 01:01 AM.


#8 lieudusty

  • Members
  • 419 posts

Posted 04 June 2014 - 01:13 AM

Why were you writing your own parser and lexer in the first place when you had the option to used luac?

#9 KillaVanilla

  • Members
  • 303 posts

Posted 04 June 2014 - 02:56 AM

View Postlieudusty, on 04 June 2014 - 01:13 AM, said:

Why were you writing your own parser and lexer in the first place when you had the option to used luac?

I didn't know / realize that I could use luac.
Writing the parser and lexer was a fun exercise, though.

Edited by KillaVanilla, 04 June 2014 - 02:56 AM.


#10 amtra5

  • Members
  • 166 posts
  • LocationMelbourne, Australia

Posted 04 June 2014 - 08:37 AM

Any way for an option to use lua 5.1? (You know where this is going :P)

Edited by amtra5, 04 June 2014 - 08:38 AM.


#11 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 04 June 2014 - 12:37 PM

View Postamtra5, on 04 June 2014 - 08:37 AM, said:

Any way for an option to use lua 5.1? (You know where this is going :P)

.. Real life CraftOS anyone? :ph34r:

#12 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 04 June 2014 - 01:49 PM

View PostJiloacom, on 04 June 2014 - 12:37 PM, said:

View Postamtra5, on 04 June 2014 - 08:37 AM, said:

Any way for an option to use lua 5.1? (You know where this is going :P)

.. Real life CraftOS anyone? :ph34r:

This OS on a Raspberry Pi, with a couple of servos: Real life turtle. *Awesome overload* :o

#13 KillaVanilla

  • Members
  • 303 posts

Posted 04 June 2014 - 04:21 PM

View Postamtra5, on 04 June 2014 - 08:37 AM, said:

Any way for an option to use lua 5.1? (You know where this is going :P)

This would be really, really easy: just replace the files in "src/lib/lua" with the source code for lua 5.1.
You might need to change things around in "src/boot/x86/main.cpp", but that's trivial.

#14 apemanzilla

  • Members
  • 1,421 posts

Posted 04 June 2014 - 04:51 PM

View PostSquidDev, on 04 June 2014 - 01:49 PM, said:

View PostJiloacom, on 04 June 2014 - 12:37 PM, said:

View Postamtra5, on 04 June 2014 - 08:37 AM, said:

Any way for an option to use lua 5.1? (You know where this is going :P/>)

.. Real life CraftOS anyone? :ph34r:

This OS on a Raspberry Pi, with a couple of servos: Real life turtle. *Awesome overload* :o/>
Pssh. Arduino + servos + lua parser.

The hard part would be turtle.dig....

#15 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 04 June 2014 - 04:57 PM

View Postapemanzilla, on 04 June 2014 - 04:51 PM, said:

View PostSquidDev, on 04 June 2014 - 01:49 PM, said:

-snip-
Pssh. Arduino + servos + lua parser.

The hard part would be turtle.dig....

Or placing blocks. The entire inventory idea would be quite hard. Oh and the floating bit. Hmmm. Quad-copter turtle?

Edited by SquidDev, 04 June 2014 - 05:01 PM.


#16 kornichen

  • Members
  • 220 posts
  • LocationGermany

Posted 04 June 2014 - 05:09 PM

Very nice. I would love to see this being able to run on a Raspberry Pi some day (which is difficult because of the ARM architecture of the Raspberry Pi).

View PostSquidDev, on 04 June 2014 - 01:49 PM, said:

View PostJiloacom, on 04 June 2014 - 12:37 PM, said:

View Postamtra5, on 04 June 2014 - 08:37 AM, said:

Any way for an option to use lua 5.1? (You know where this is going :P)

.. Real life CraftOS anyone? :ph34r:

This OS on a Raspberry Pi, with a couple of servos: Real life turtle. *Awesome overload* :o

But anyway it would be very interesting to have an operating system which acts like the old C64 BASIC but with Lua. Would be interesting to thing with it.

#17 KillaVanilla

  • Members
  • 303 posts

Posted 04 June 2014 - 10:31 PM

I could try porting this to ARM, if I had an emulator for it.
(Well, I do have a raspberry pi in the drawer, so...)

It shouldn't be too hard, though I'd have to rewrite parts all of the memory management and allocation system, as well as interrupt handling.
I think that I have the time (whoo summer break) and the dedication for this.
Edit: Porting this to ARM seems surprisingly easy (most of the code I've written is platform-independent C++), but debugging kinda looks like a pain..

Does anyone have experience writing assembly for ARM11?
I'd appreciate the assistance.

Edited by KillaVanilla, 05 June 2014 - 05:51 AM.


#18 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 05 June 2014 - 01:21 PM

View PostSquidDev, on 04 June 2014 - 04:57 PM, said:

View Postapemanzilla, on 04 June 2014 - 04:51 PM, said:

View PostSquidDev, on 04 June 2014 - 01:49 PM, said:

-snip-
Pssh. Arduino + servos + lua parser.

The hard part would be turtle.dig....

Or placing blocks. The entire inventory idea would be quite hard. Oh and the floating bit. Hmmm. Quad-copter turtle?

Pssh! All we have to do is break the laws of physics! It can't be that hard, Minecraft has already done it.

#19 Lua.is.the.best

  • Members
  • 76 posts

Posted 09 June 2014 - 05:34 AM

Written in C++, eh?
Could whip up some math .h files here!
All your doing is using cin to input numbers..
Then use operators to do stuff!

#20 Lua.is.the.best

  • Members
  • 76 posts

Posted 09 June 2014 - 05:40 AM

With those .h files, you could create:
Price calculator
Regular calculator
And using cout and cin you could create:
Basic Hello message
Username and password system (:P, secure if we could find a way to encrypt it xD)
and way more!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users