How to rewrite xv6 from scratch?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
dzwduan
Posts: 1
Joined: Wed Jul 29, 2020 1:36 am

How to rewrite xv6 from scratch?

Post by dzwduan »

I dont know how to use Makefile to reimplement an os .which files should i first write and how to write my makefile to verification ?
I have rewrite bootasm.S and bootmain.c,but the Makefile need kernel ,and kernel need more.Thus i dont know how to develop it
User avatar
acccidiccc
Member
Member
Posts: 38
Joined: Sun Mar 21, 2021 1:09 pm
Location: current location

Re: How to rewrite xv6 from scratch?

Post by acccidiccc »

Hello, I advise you to learn how makefiles work: they are very useful, tedious, but useful.

Code: Select all

#basic makefile (not applicable to the xv6 project)
.PHONY clean # if you have a directory named clean, it gets ignored so you can $ make clean

CFLAGS=-ffreestanding -Iinc #freestanding, that means that you it is compiled without system files -Iinc looks for headers in inc

kernel:
    gcc $$(find  ./ -name '*.c' -or -name '*.S') $(CFLAGS) # cflags are the ones specified above, gcc is the compiler !INSERT CROSSCOMPILER HERE!
   # find name '*.c" finds all c source files and .S files in the current directory, change ./ to your source directory
   # do a few more for obj's and stuff


#


dzwduan wrote:how to write my makefile to verification

what do you mean? to verify what?
I think you mean to use the xv6 makefile right?

remember xv6 is a not easy to achieve, I myself am not very experienced, but I know that getting to a tasking operating system is hard.
you do not need to write it from scratch, modify and add functionality yourself, or start with the barebones given on the osdev wiki
(wiki.osdev.org/barebones)
as this is old and your only post, maybe you have given up, but try again later if you want and have got a better grasp of makefiles and etc.
note: OSDev takes time, a lot of time, at least for me. as much as a full time job, thankfully I'm a student so I got that time)

also theres a page on the wiki, which specifies the order you should do things in.

start with a basic way of communicating to you, via a serial buffer or vga. such as printf. print to serial is the next, as it is not volatile like the vga buffer is. then make an interrupt handling system, with exceptions, a tutorial is on the wiki.
if you don't understand any thing, google it with the suffix osdev eg. multithreading osdev.
grab an intel manual for the target processor. (x86 programmer manual) or volume 3 of the x86_64 specification.


GOOD LUCK
iustitiae iniustos iudicat
Post Reply