Tuesday, June 27, 2006

.bss ???

What is a BSS segment?

Most of the guys ask me this question. This is some segment in your application similar to .text, .data and .stack. All the un-initialized variables go into this section, rather than .data segment. This is to reduce the size of your .exe or .o files.

For example, if you have declared a variable "int a", it goes into the .bss segment. The compiler will not allocate space for "a" in the executable file. Instead, it will accumulate such variables and calculate the total number of bytes and add it in the header.

So your application will not have the space allocated, when it is in secondary memory. Once it is loaded into the primary memory, the number of bytes for the .bss segment is read from the header and allocated in RAM.

- Alexander.

Friday, April 28, 2006

Kernel @ 1 MB

Till now, secondary loader loads the kernel at 0x9000. Now, the loader will load the kernel at 1MB mark. Also, I have created a linker.ld file to link the kernel at 0x100000. Below is my linker.ld script:

ENTRY (_start32)

.text 0x100000 :
{ *(.text) }

.data :
{ *(.data) }

.bss :
{ *(.bss) }
  • I have implemented PMM (Physical Memory Manager) in my kernel, which runs below VMM (Virtual Memory Mapper). Though, it is in its priliminary stage.
  • init_pmm() - Will initialize the stack, which holds the address of free pages. The stack is initialized based on the memory map passed by the LEXOS' secondary bootloader. PMM will ignore any usable memory below 1 MB, as it is reserved for V86 mode.
  • alloc_page() - Will pop a free page from the stack and return it to the calling thread. The PMM returns the physical address of the free page. This address will be mapped by the VMM to the process' virtual address space.
  • free_page() - Will push the page to be freed into the stack.