278 posts
Posted 02 May 2014 - 08: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/OmamoriThe makefile is dependent on a cross-compiler I've set up on my development machine – see
this for details.
Edited on 04 June 2014 - 02:52 AM
139 posts
Posted 02 May 2014 - 10: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/SamyPesse/How-to-Make-a-Computer-Operating-System cause it has some of the libraries t¿you need alredy implemented
475 posts
Posted 03 May 2014 - 03: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 on 03 May 2014 - 01:21 PM
278 posts
Posted 03 May 2014 - 07:36 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?
I'm planning on compiling the Lua code to native machine code, though anything could be subject to change at this point.
195 posts
Location
Cambridgeshire, England
Posted 03 May 2014 - 08: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.
197 posts
Location
Czech Republic
Posted 04 May 2014 - 03: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)
278 posts
Posted 04 June 2014 - 01: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.
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 on 04 June 2014 - 12:01 AM
475 posts
Posted 04 June 2014 - 02:13 AM
Why were you writing your own parser and lexer in the first place when you had the option to used luac?
278 posts
Posted 04 June 2014 - 03:56 AM
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 on 04 June 2014 - 01:56 AM
321 posts
Location
Melbourne, Australia
Posted 04 June 2014 - 09:37 AM
Any way for an option to use lua 5.1? (You know where this is going :P/>)
Edited on 04 June 2014 - 07:38 AM
598 posts
Location
The United States
Posted 04 June 2014 - 01:37 PM
Any way for an option to use lua 5.1? (You know where this is going :P/>)
.. Real life CraftOS anyone? :ph34r:/>
1426 posts
Location
Does anyone put something serious here?
Posted 04 June 2014 - 02:49 PM
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/>
278 posts
Posted 04 June 2014 - 05:21 PM
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.
1610 posts
Posted 04 June 2014 - 05:51 PM
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….
1426 posts
Location
Does anyone put something serious here?
Posted 04 June 2014 - 05:57 PM
-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 on 04 June 2014 - 04:01 PM
235 posts
Location
Germany
Posted 04 June 2014 - 06: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).
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.
278 posts
Posted 04 June 2014 - 11: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 on 05 June 2014 - 04:51 AM
598 posts
Location
The United States
Posted 05 June 2014 - 02:21 PM
-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.
120 posts
Posted 09 June 2014 - 06: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!
120 posts
Posted 09 June 2014 - 06: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!
120 posts
Posted 10 June 2014 - 12:13 AM
Oh, you have pwd.h :P/>
301 posts
Location
Whenever, Wherever!
Posted 15 June 2014 - 06:41 AM
Theres a guide about writing OS's for the raspberry pi in assembly. Goes pretty in depth for a beginners guide. (Images, text, interrupts)
http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/
278 posts
Posted 17 June 2014 - 06:53 PM
Theres a guide about writing OS's for the raspberry pi in assembly. Goes pretty in depth for a beginners guide. (Images, text, interrupts)
http://www.cl.cam.ac...i/tutorials/os/
This does seem very interesting, but where does it start talking about interrupts?
Also, I'm also looking specifically about how paging works on an ARM.
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!
I actually have integrated a C standard library into my kernel, but for various reasons I don't use it very often (or at all) in the code I've written.
Also, this OS doesn't actually
have standard input (or file streams, for that matter) implemented yet. The only way to get input is to call into the keyboard driver itself.