syntax help

Philip Herron herron.philip@googlemail.com
Sat Jan 3 23:30:00 GMT 2009


Hey Guys

This might be kind of silly question but i don't understand this code
segment:

====================================================
//our first page table comes right after the page directory
unsigned int *first_page_table = page_directory + 0x1000;

// holds the physical address where we want to start mapping these pages
to.
// in this case, we want to map these pages to the very beginning of memory.
unsigned int address = 0; 
unsigned int i;

//we will fill all 1024 entries, mapping 4 megabytes
for(i = 0; i < 1024; i++)
{
    first_page_table[i] = address | 3; // attributes: supervisor level, read/write, present.
    address = address + 4096; //advance the address to the next page boundary
}
==================================================

This is taken of: http://wiki.osdev.org/Setting_Up_Paging
Been working at a small os project of my own: http://gitorious.org/projects/zepher

For something in my spare time, starting to love gnu as. Anyways the thing i don't understand is:

first_page_table[i] = address | 3;

I don't know what this does. first_page_table was it not just an integer? Or does this go trough each 
byte in the int and set rights? with the '|' like value address and rights 3 or something. I haven't really seen this 
syntax so sorry if it sounds really stupid!

One more thing is there some documentation on the __atribute__ system in gcc i have set some structs to be packed, 
is there some more documentation to see what other modes gcc supports for data types?

Thanks

-Phil
http://redbrain.co.uk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20090103/5a19d983/attachment.sig>


More information about the Gcc-help mailing list