mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
93 lines
5.5 KiB
HTML
93 lines
5.5 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
|
||
|
<html><head>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
|
||
|
<meta http-equiv="Content-Language" content="en-us"><title>Product</title>
|
||
|
|
||
|
<link rel="stylesheet" type="text/css" href="../style.css"></head>
|
||
|
<body style="background-color: rgb(255, 255, 255);"><h3><a name="title" href="http://www.eluaproject.net/en/Booting_your_PC_in_eLua" class="local">Booting your PC in eLua</a></h3>
|
||
|
|
||
|
<div class="content">
|
||
|
|
||
|
<p>That's right: after following this tutorial, your PC will boot
|
||
|
directly into Lua! No OS there (this explains why the boot process is
|
||
|
so fast), just you and Lua. You'll be able to use the regular Lua
|
||
|
interpreter to write your programs and even use "dofile" to execute Lua
|
||
|
code.</p>
|
||
|
|
||
|
<h2>Details</h2>
|
||
|
|
||
|
<p>Booting Lua involves using the well known <a href="http://www.gnu.org/software/grub/">GRUB</a> that will be used to load a <a href="http://www.gnu.org/software/grub/manual/multiboot/">multiboot</a>
|
||
|
compliant ELF file that contains our eLua code. Since the eLua code and
|
||
|
the build instructions are not available yet, I'll be providing a
|
||
|
direct link to the ELF file. The code runs in protected mode, so you
|
||
|
have access to your whole memory. The code does not access any kind of
|
||
|
storage device (HDD, CDROM, floppy), so if you're worried that it might
|
||
|
brick your system, you can relax now :) I'm only using some very basic
|
||
|
keyboard and VGA "drivers", so all you're risking is a system freeze
|
||
|
(even this is highly unlikely), nothing a good old RESET can't handle
|
||
|
(be sure to use the hardware reset though, CTRL+ALT+DEL is not handled
|
||
|
by the code). But just in case, see also the next section.</p>
|
||
|
|
||
|
<h2>Disclaimer</h2>
|
||
|
|
||
|
<p><strong>As already mentioned, the code won't try to access any kind
|
||
|
of storage (HDD, CDROM, floppy), not even for reading, so you don't
|
||
|
need to worry about that. Also it doesn't try to reprogram your video
|
||
|
card registers, so it can't harm it or your monitor. It only implements
|
||
|
a "protected mode keyboard driver" that can't physically damage
|
||
|
anything in your system. In short, I made every effort to make the code
|
||
|
as harmless as possible. I tested it on 5 different computers and in 2 <a href="http://www.virtualbox.org/">VirtualBox</a>
|
||
|
emulators, and nothing bad happened. That said, there are no warranties
|
||
|
of any kind. In the very unlikely event that something bad does happen
|
||
|
to your system, you have my sincere sympathy, but I can't be held
|
||
|
responsible for that.</strong></p>
|
||
|
|
||
|
<h2>Prerequisites</h2>
|
||
|
|
||
|
<p>To boot your computer in Lua you'll need:</p>
|
||
|
|
||
|
<ul><li>a 386 or better computer running Linux. I actually tested
|
||
|
this only on Pentium class computers, but it should run on a 386
|
||
|
without problems.</li><li><a href="http://www.gnu.org/software/grub/">GRUB</a>.
|
||
|
Since you're running Linux, chances are you're already using GRUB as
|
||
|
your bootloader. If not, you must install it. You don't need to install
|
||
|
it on your HDD; a floppy, an USB stick or even a CDROM will work as
|
||
|
well. I won't cover the GRUB installation procedure here, just google
|
||
|
for "install grub on floppy/usb/cdrom" and you'll sure find what you're
|
||
|
looking for. You can try for example <a href="http://orgs.man.ac.uk/documentation/grub/grub_3.html">here</a>, <a href="http://www.freesoftwaremagazine.com/articles/grub_intro/">here</a> or <a href="http://www.mayrhofer.eu.org/Default.aspx?pageindex=6&pageid=45">here</a>.</li><li>The eLua ELF file. Download it from <a href="http://elua.berlios.de/surprise">here</a>. OR <a href="http://www.eluaproject.net/en/Downloads">download eLua</a> and compile it for the i386 architecture using a toolchain that you can build by following <a href="http://www.eluaproject.net/en/Building_GCC_for_i386">this tutorial</a>.</li><li>a text editor to edit your GRUB configuration file.</li></ul>
|
||
|
|
||
|
|
||
|
<p>The rest of this tutorial assumes that you're using Linux with GRUB,
|
||
|
and that GRUB is located in /boot/grub, which is true for many Linux
|
||
|
distributions (I'm using Ubuntu 8.04).</p>
|
||
|
|
||
|
<h2>Let's do this</h2>
|
||
|
|
||
|
<p>First, copy the <a href="http://elua.berlios.de/surprise">eLua ELF file</a> to your "/boot" directory:</p>
|
||
|
<pre><code>$ sudo cp surprise /boot<br></code></pre>
|
||
|
|
||
|
<p>Next you need to add another entry to your GRUB menu file (/boot/grub/menu.lst). Edit it and add this entry:</p>
|
||
|
|
||
|
<pre><code> title Surprise!<br> root (hd0,0)<br> kernel /boot/surprise<br> boot<br></code></pre>
|
||
|
|
||
|
|
||
|
<p>You may need to modify the root (hd0,0) line above to match your
|
||
|
boot device. The best way to do this is to look in the menu.lst file
|
||
|
for the entry that boots your Linux kernel. It should look similar to
|
||
|
this:</p>
|
||
|
|
||
|
<pre><code> title Ubuntu, kernel 2.6.20-16-generic<br> root (hd0,2)<br> kernel /boot/vmlinuz-2.6.20-16-generic<br> initrd /boot/initrd.img-2.6.20-16-generic<br> savedefault <br></code></pre>
|
||
|
|
||
|
|
||
|
<p>After you find it, simply use the root (hdx,y) line from that entry
|
||
|
(root (hd0,2) in the example above) in your newly created entry instead
|
||
|
of root (hd0,0).
|
||
|
That's it! Now reboot your computer, and when the GRUB boot menu
|
||
|
appears, choose "Surprise!" from it. You can even type dofile
|
||
|
"/rom/bisect.lua" to execute the "bisect.lua" test file. Enjoy!
|
||
|
As usual, if you need more details, you can <a href="http://www.eluaproject.net/en/Contact">contact us</a>.
|
||
|
Also, if you want to have you own USB stick that boots Lua, let me
|
||
|
know. If enough people manifest their interest in this, I'll add
|
||
|
another tutorial on how to do it (I already have an USB stick that
|
||
|
boots Lua, of course :) ).</p>
|
||
|
</div></body></html>
|