Philip Herron wrote: > 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! An int is four bytes: if an int is at address 0x1000, the next int is at address 0x1004, and so on. Ints are almost always aligned, so the lowest two bits of an int* are almost always zero. Knowing that they are zero, we can use these lowest two bits for something else, such as flags. > 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? Have you found the gcc manual? Andrew.