Date: Mon, 10 Dec 2012 02:38:03 -0500 From: Zaphod Beeblebrox <zbeeble@gmail.com> To: Aryeh Friedman <aryeh.friedman@gmail.com> Cc: FreeBSD Mailing List <freebsd-hackers@freebsd.org> Subject: Re: using FreeBSD to create a completely new OS Message-ID: <CACpH0Mfj77ccSOeeoaQfYtvXAWB_=gsJMKK7WoFckj%2BdJotggw@mail.gmail.com> In-Reply-To: <CAGBxaX=y9yLBymKX8Psmer0sPFWCgAFy3gs%2BtgU7waQt2g6hKA@mail.gmail.com> References: <CAGBxaX=y9yLBymKX8Psmer0sPFWCgAFy3gs%2BtgU7waQt2g6hKA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Dec 9, 2012 at 11:48 PM, Aryeh Friedman <aryeh.friedman@gmail.com> wrote: > For personal hobby reasons I want to write an OS completely from > scratch (due to some aspects of the design no existing OS is a > suitable starting place)... what I mean is I want to start with the > MBR (boot0) and go on from there... I only have one *REAL* machine to Well... most would say that the interesting part of an OS has very little to do with the loader, but who am I to judge: maybe a loader is interesting for you. There are quite a few things that can be loaded and useful from an MBR. Pretty much any machine will provide you with a boot environment that has lived longer than any other. It's pretty much DOS without a filesystem, tho. In freebsd, you want to look at /boot/mbr and maybe (later) /boot/loader (or one of it's variants). > work with which means I need to work with something like > emulators/virtualbox-ose... I also want to do as many automated tests > as possible (for example seeing if the installer copied the MBR [and > later other stuff] correctly to the virtual HDD).... for this reason I > have a few questions on vb (or perhaps QEMU if not possible in vb): > > 1. Can it be scripted? > 2. Is there any documentation on the various virtual HDD formats and > such (that way I can check the "physical" drive and not by indirect > query)? The format of an MBR (master boot record) is documented everywhere. I'm pretty sure wikipedia has a good article on it. This mailing list is not google, BTW. > Also can people give me some idea of a good general > development/testing framework.... the one I have in mind so far is: > > 1. Write enough of the OS in FreeBSD to boot and give a command prompt > and then develop using it (assume that there is a working compilor > [note I am doing it completely in Java (note 1) and will be using > either gjava (gcc) or writing my own compiler]) > > Notes: > > 1. Due to OS's needing to address physical RAM directly (DMA mapped > I/O) I will be introducing some form of ptr's into java with the > compiler or native My first thought was the humor of getting java to deal with segment registers. It's hard enough in C. But in all seriousness, most systems go from the firmware to something like a bootblock (often called a stage one boot) to a smarter bootloader (stage two boot) to activating the OS. In a PC-ish world for FreeBSD, that's BIOS->/boot/mbr->/boot/loader->kernel. Specifically locore.s (note: assembly language file). locore.s is one of a few regions of kernels that are generally _not_ written in high level languages. Other's include the very lowest level of the scheduler and the virtual memory manager. In locore's case, you can't express the special instructions (for a PC) to exit real mode and enter virtual mode (or some such transformation --- I really haven't been there in awhile). Note that FreeBSD boots on a number of things and that each boot process is a little bit different. If you're going to write an OS from scratch, you might start with something _way_ simpler than FreeBSD. Minix would be a good choice. I think it still comes as a book you buy with bootable code. If you haven't done OS work before, the book part might get you going faster than diving into the FreeBSD codebase.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACpH0Mfj77ccSOeeoaQfYtvXAWB_=gsJMKK7WoFckj%2BdJotggw>