"Salah satu tanda bergantung pada amal adalah berkurangnya harapan tatkala gagal."

Kernel 2.4 code glosary

by danang.wijanarko@gmail.com

 

mm/boomem.c {__alloc_bootmem_core}
It tooks me a while to understand this.
	  offset = 0;
if (align && /* if the alignment is power of 2 and specified, ... */
(bdata->node_boot_start & (align - 1UL)) != 0) /* and the address of bdata->node_boot_start is agree with the alignment */
offset = (align - (bdata->node_boot_start & (align - 1UL))); /* then calculate the offset */
offset >>= PAGE_SHIFT;
bootmem_data_t
Code commentary
	  typedef struct bootmem_data {
unsigned long node_boot_start; /* The start of the bootmem memory (the first page, normally 0). */
unsigned long node_low_pfn; /* Contains the end of low memory of the node. */
void *node_bootmem_map; /* Start of the bootmem bitmap.
unsigned long last_offset; /* This is used to store the offset of the last byte allocated in the previous
allocation from last pos to avoid internal memory fragmentation */
unsigned long last_pos; /* This is used to store the page frame number of the last page of the previous
allocation. It is used in the function alloc bootmem core() to
reduce internal fragmentation by merging contiguous memory requests. */


} bootmem_data_t;
SYMBOL_NAME(X), SYMBOL_NAME_STR(X), SYMBOL_NAME_LABEL(X)
Taken from include/linux/linkage.h to define some symbol in the binary.
	  #define SYMBOL_NAME_STR(X) #X

#define SYMBOL_NAME(X) X

#ifdef __STDC__
#define SYMBOL_NAME_LABEL(X) X##:
#else
#define SYMBOL_NAME_LABEL(X) X/**/:
#endif
Patched on bootsect.S
This is the preliminare data to portray the image. About the size, the component size, default root device, and a few others.
	  .org 497
setup_sects: .byte SETUPSECS // overwritten by tools/build
root_flags: .word ROOT_RDONLY
syssize: .word SYSSIZE // overwritten by tools/build
swap_dev: .word SWAP_DEV
ram_size: .word RAMDISK
vid_mode: .word SVGA_MODE
root_dev: .word ROOT_DEV // overwritten by tools/build
// but this would be overwritten
// again by command line
boot_flag: .word 0xAA55
bad_sig() on setup.S
Note that old bootloaders (old versions of LILO) could only load the first 4 sectors of image (1 for bootsect and 3 for setup), which is why there is code in setup to load the rest of itself if needed (means that setup size > 3 sectors).
How do we know the size of setup ? Yes that's it, via:
	  tools/build -b bbootsect bsetup compressed/bvmlinux.out CURRENT > bzImage
Root device is (8, 8)
Boot sector 512 bytes.
Setup is 2517 bytes.
System is 351 kB
See !, the arch/i386/boot/tools/build.c patches the size to the bootsect.S. And then any loader could load how many bytes from the kernel image for setup. What about the offset? setup is always patched right after bootsect, and the bootsect size is always 512 Bytes. Then you've sould got the idea.

 

- d

"Bekatul Port" Personal Enterprise Number (PEN) registered @ IANA OID

ASN.1 Notation: {iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 30347}

Dot Notation: 1.3.6.1.4.1.1.30347

IRI Notation: oid:/ISO/Identified-Organization/6/1/4/1/30347


View Stat Counter