Strange magic number in Minix

154 views
Skip to first unread message

javi68yt2

unread,
Mar 14, 2025, 9:31:20 AMMar 14
to minix3
Hi. I'm no newbie in Minix, but dusting my old Minix 1.0 off... and there are an strange magic number in 0x526F, in mpx88.s:

|*===========================================================================*
|* data      *
|*===========================================================================*
.data
begdata:
_sizes:  .word 0x526F | this must be the first data entry (magic #)
 .zerow 7 | build table uses prev word and this space
bx_save: .word 0 | storage for bx
ds_save: .word 0 | storage for ds
ret_save:.word 0 | storage for return address
lds_low: .word 0,0 | storage used for restoring bx
ttyomess: .asciz "RS232 interrupt"

.bss
begbss:

In tools/build.c that number is identify as maker:
#define KERNEL_D_MAGIC 0x526F   /* identifies kernel data space */

However, in kernel\main.c that positions are managed as an array of 8 integers, kernel size:

base_click = BASE >> CLICK_SHIFT;
size = sizes[0] + sizes[1]; /* kernel text + data size in clicks */
mm_base = base_click + size; /* place where MM starts (in clicks) */

Is sizes[0] == 0x526F?
Kernel text size?
How can it know this? Why is it a constant intead of a calculated value?

Moreover, build.c too:

/* See if the magic number is where it should be in the kernel. */
  data_offset = 512L + (long)sizes[KERN].text_size;    /* start of kernel data */
  i = (get_byte(data_offset+1L) << 8) + get_byte(data_offset);
  if (i != KERNEL_D_MAGIC)  {
pexit("kernel data space: no magic #","");
  }
 
  for (i = 0; i < PROGRAMS - 1; i++) {
        t = sizes[i].text_size;
        d = sizes[i].data_size;
        b = sizes[i].bss_size;
        if (sizes[i].sep_id) {
                text_clicks = t >> CLICK_SHIFT;
                data_clicks = (d + b) >> CLICK_SHIFT;
        } else {
                text_clicks = 0;
                data_clicks = (t + d + b) >> CLICK_SHIFT;
        }
...
}

sizes[KERN].text_size == sizes[0].text_size

Is size from kernel the same reference used in build.c?
How can it be, at the same time, both a magic number?

Thanks in advance
Reply all
Reply to author
Forward
0 new messages