Skip to content

Commit

Permalink
first initial public version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaku committed Apr 22, 2018
1 parent a598bab commit 62cd094
Show file tree
Hide file tree
Showing 292 changed files with 35,374 additions and 0 deletions.
37 changes: 37 additions & 0 deletions CODING
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Fiwix kernel coding standards
-------------------------------------------------------------------------------
It's easier on everyone if all authors working on a shared code base are
consistent in the way they write their programs. Fiwix has the following
conventions in its code:

- Use of snake_case (multi-word names are lower_case_with_underscores) for
everything except for macro and constant names.

- No space after the name of a function in a call.
For example, printk("hello") not printk ("hello").

- No space after keywords "if", "for", "while", "switch".
For example, if(x) not if (x).

- Space before braces.
For example, if(x) { not if(x){.

- Space between operands.
For example, for(n = 0; n < 10; n++), not for(n=0;n<10;n++).

- Beginning-of-line indentation via tabs, not spaces.

- Preprocessor macros are always UPPERCASE.

- Pointer types have spaces: (uint16_t *) not (uint16_t*).

- Comments in code are always as in C89 /* ... */.

- Multiline comments start always with a capital letter and the last sentence
ends with a period.

- In a function definition, the function name starts a new line.
Then you can grep -n '^foo' */*.c to find the definition of foo.

- Functions that take no arguments are declared as f(void) not f().

Empty file added Changes
Empty file.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2018 Jordi Sanfeliu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# fiwix/Makefile
#
# Copyright 2018, Jordi Sanfeliu. All rights reserved.
# Distributed under the terms of the Fiwix License.
#

TOPDIR := $(shell if [ "$$PWD" != "" ] ; then echo $$PWD ; else pwd ; fi)
INCLUDE = $(TOPDIR)/include

ARCH = -m32
CPU = -march=i386

DEBUG = -D__DEBUG__ #-D__2DEBUG__

CC = $(CROSS_COMPILE)gcc $(ARCH) $(CPU) #$(DEBUG)
LD = $(CROSS_COMPILE)ld

CFLAGS = -I$(INCLUDE) -Wall -Wstrict-prototypes -ffreestanding -O2 #-Wextra
LDFLAGS = -m elf_i386 -nostartfiles -nostdlib -nodefaultlibs -nostdinc

DIRS = kernel kernel/syscalls mm fs drivers/block drivers/char lib
OBJS = kernel/kernel.o kernel/syscalls/syscalls.o mm/mm.o fs/fs.o \
drivers/block/block.o drivers/char/char.o lib/lib.o

export CC LD CFLAGS LDFLAGS INCLUDE

all:
@echo "#define UTS_VERSION \"`date`\"" > include/fiwix/version.h
@for n in $(DIRS) ; do (cd $$n ; $(MAKE)) ; done
$(LD) -N -T fiwix.ld $(LDFLAGS) $(OBJS) -o fiwix
nm fiwix | sort | gzip -9c > System.map.gz

clean:
@for n in $(DIRS) ; do (cd $$n ; $(MAKE) clean) ; done
rm -f *.o fiwix System.map.gz

floppy:
mkfs.minix -n 30 /dev/fd0
mount -t minix /dev/fd0 /mnt/floppy
@mkdir -p /mnt/floppy/boot/grub
@echo "(fd0) /dev/fd0" > /mnt/floppy/boot/grub/device.map
@grub-install --root-directory=/mnt/floppy /dev/fd0
@tools/MAKEBOOTDISK
@cp -prf tools/etc/* /mnt/floppy/etc
@cp fiwix /mnt/floppy/boot
@cp System.map.gz /mnt/floppy/boot
@cp tools/install.sh /mnt/floppy/sbin
umount /mnt/floppy

floppy_update:
mount -t minix /dev/fd0 /mnt/floppy
cp fiwix /mnt/floppy/boot
cp System.map.gz /mnt/floppy/boot
umount /mnt/floppy

140 changes: 140 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
Fiwix kernel release 1.0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~

Fiwix is an operating system kernel, written by Jordi Sanfeliu from scratch,
based on the UNIX architecture and fully focused on being POSIX compatible.
It is designed and developed mainly as a hobby OS but also for educational
purposes, therefore the kernel code is kept as simple as possible.

It runs on the i386 (x86 32bit) hardware architecture and is compatible with
a good base of existing GNU applications. It offers many UNIX-like features:

- Mostly written in C language (Assembler only used in the needed parts).
- GRUB Multiboot Specification v1 compliant.
- Full 32bit protected mode non-preemptive kernel.
- For i386 processors and higher.
- Preemptive multitasking.
- Protected task environment (independent memory address per process).
- Interrupt and exception handling.
- POSIX-compliant (mostly).
- Process groups, sessions and job control.
- Interprocess communication with pipes and signals.
- BSD file locking mechanism (POSIX restricted to file and advisory only).
- Virtual memory management up to 4GB (1GB physical only and no swapping yet).
- Demand paging with Copy-On-Write feature.
- Linux 2.0 ABI system calls compatibility (mostly).
- ELF-386 executable format support (statically and dynamically linked).
- Round Robin based scheduler algorithm (no priorities yet).
- VFS abstraction layer.
- Minix v1 and v2 filesystem support.
- EXT2 filesystem support (read only) with 1KB, 2KB and 4KB block sizes.
- Linux-like PROC filesystem support (read only).
- PIPE pseudo-filesystem support.
- ISO9660 filesystem support with Rock Ridge extensions.
- RAMdisk device support.
- SVGAlib based applications support.
- Keyboard driver with Linux keymaps support.
- Parallel port printer driver support.
- Floppy disk device driver and DMA management.
- IDE/ATA hard disk device driver.
- IDE/ATA ATAPI CDROM device driver.

Fiwix is distributed under the terms of the MIT License, see the LICENSE file
for more details.


COMPILING
===============================================================================
Before compiling you might want to tweak the kernel configuration by changing
the values in the 'include/fiwix/config.h' file.

The command needed to make a full compilation of the Fiwix kernel is:

make clean ; make

This will create the files 'fiwix' (the kernel itself) and 'System.map.gz' (the
symbol table) in the root directory of the source code tree.

Keep in mind that the kernel doesn't do anything on its own, you need to create
a user-space environment to make use of it. Upon booting, the kernel mounts the
root filesystem and tries to run '/sbin/init' on it, so you need to provide this
program yourself.


TESTING
===============================================================================
To create a complete bootable floppy disk you need to download the Fiwix Test
Suite archive and symlink the directory 'tools/' into the root directory of the
kernel source code. Then insert a floppy disk into the drive and then type the
following:

make floppy

If you only want to update an existing floppy disk with a newer or modified
kernel version, then type the following:

make floppy_update


If you don't have a floppy drive but a bootable CDROM IDE/ATA drive, you can
create your own Fiwix Installation CDROM by using your current operating system
(i.e. GNU/Linux). To do this, you might want to use the scripts and tools that
come with the Fiwix Test Suite archive.

The scripts to create such bootable images cannot be executed under Fiwix
because they need support for the loop device and the ISO9660 creation tools.

To create your own bootable CDROM ISO image you must do the following steps:

1. Download the Fiwix Installation CDROM ISO image.
2. Download the Fiwix floppy image or create a new one with 'make_image'.
3. Edit the 'make_cdrom' script and adjust the values of the $INSTALLCD and
$FIWIX_VERSION variables.
4. Execute './make_cdrom'.


INSTALLING
===============================================================================
Please keep in mind that this is a kernel in its very early stages and may well
have serious bugs and broken features which have not yet been identified or
resolved.

Let me repeat that.

Please keep in mind that this is a kernel in its very early stages and may well
have serious bugs and broken features which have not yet been identified or
resolved.

*****************************
*** USE AT YOUR OWN RISK! ***
*****************************


You can proceed to install the Fiwix OS on a hard disk either once booted from
the floppy or from the Live CDROM. If you chosen the former, you will also need
the Live CDROM inserted in order to install the packages that form all the
system environment.

I recommend using QEMU or VMware Player, but if you want to use it on a real
hardware you will need a PC with either a bootable floppy 1.44MB drive or an
IDE/ATAPI CDROM drive.

The minimal requirements to use Fiwix are as follows:

- Standard IBM PC-AT architecture.
- i386 processor or higher.
- 2MB of RAM memory (64MB recommended).
- Floppy disk (3.5", 1.44MB) or IDE/ATAPI CDROM.
- 500MB IDE Hard disk (1GB recommended).

Let the system boot either from a floppy or a CDROM, and when you are ready
just type:

install.sh


Happy hacking.

--
Copyright (C) 2018, Jordi Sanfeliu.
http://www.fiwix.org
13 changes: 13 additions & 0 deletions THANKS
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
THANKS!

A huge THANKS to all people who created their own hobby, and not so hobby,
operating systems and made them freely available on Internet.

From those simple "Hello world!\n" kernels to a real self-hosting operating
system, their projects were a invaluable source of information and inspiration
to create the Fiwix kernel.

A special thanks to OSDEV Community for their tutorials, documents, wikis, etc.

Jordi Sanfeliu
http://www.fiwix.org
18 changes: 18 additions & 0 deletions docs/kernel-parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Fiwix kernel parameters
=======================

The following is a list of the current kernel parameters:

console= Set the output console device
Options: /dev/tty[1..12]

noramdisk Disable RAM disk driver

ramdisksize= Size of the RAM disk device in kilobytes (KB)

root= Root filesystem
Options: /dev/fd0, /dev/hda1, ...

rootfstype= Set the root filesystem type
Options: minix, ext2, iso9660

78 changes: 78 additions & 0 deletions docs/kmem_layout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Fiwix Kernel Memory Address Space
=================================

0x00000000
.
.
0x00090000
+-------------------+
| 4KB kpage_dir | this page will be reused once the definitive
| only used at boot | kpage_dir is installed
+-------------------+
.
0x00100000
+-------------------+
| .text section | kernel binary (fiwix)
+-------------------+
| .data section |
+-------------------+
| .bss section |
+-------------------+
+ PAGE_SIZE
+-------------------+ this page prevents stack reaching .bss section
| NULL | this page *shouldn't be* mapped so it will GPF,
+-------------------+ its purpose is to capture out-of-bounds addresses
+ PAGE_SIZE /\
+-------------------+ ||
| stack pointer | grows downwards
+-------------------+ kernel has only 4KB space for its own stack
+ PAGE_SIZE
+-------------------+
| kpage_dir |
+-------------------+
+ PAGE_SIZE
+-------------------+
| kpage_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| proc_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| buffer_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| buffer_hash_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| inode_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| inode_hash_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| fd_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| mount_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| RAMdisk |
| (default is 4MB) |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| page_hash_table |
+-------------------+
0x.....000 (page aligned)
+-------------------+
| page_table |
+-------------------+

19 changes: 19 additions & 0 deletions drivers/block/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# fiwix/drivers/block/Makefile
#
# Copyright 2018, Jordi Sanfeliu. All rights reserved.
# Distributed under the terms of the Fiwix License.
#

.S.o:
$(CC) -traditional -I$(INCLUDE) -c -o $@ $<
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<

OBJS = dma.o floppy.o part.o ide.o ide_hd.o ide_cd.o ramdisk.o

block: $(OBJS)
$(LD) $(LDFLAGS) -r $(OBJS) -o block.o

clean:
rm -f *.o

Loading

0 comments on commit 62cd094

Please sign in to comment.