protected memory

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Ninjarider
Member
Member
Posts: 62
Joined: Fri Jun 29, 2007 8:36 pm

protected memory

Post by Ninjarider »

got ahold of an intel manual and been doing some reading.
thinking about starting off with it just in case down the road.
does anyone have an os that has this functioning.

is there any memory fields that i should not touch. (a-block ie video, and bios areas, ?????)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

There are two ways (in X86) of protecting memory - paging and segmentation.

I don't use segmentation.

I have paging working and have user/supervisor level protection and have had that for quite a while now.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

The best thing is to not touch anything that you do not know about. For most starting people that means 'do not write to anything but RAM that you know is present or video memory'. You'll probably figure about other places you can write to yourself sooner or later.

The same can be said about I/O ports, btw.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

I use paging. I found C++ to be a lot of help, since each process is an instance of a Process class, which has it's own linked list of pages. When a task switch is done, I disable the the paging bit of CR0, regenerate the page table (just loop through the linked list of kernel then process pages and add them to the page table/directories), and re-enable the paging bit of CR0.

I know it's not the quickest way (some people give each process it's own page directory in memory and just swap the value of CR3 instead of generating a new one), but it works for me and and saves memory.
My OS is Perception.
Post Reply