mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-29 04:04:02 +03:00
u3: remove references to u3a_bits/u3a_bytes/words/pages
This commit is contained in:
parent
7c9167b6ae
commit
eec9354849
@ -13,15 +13,15 @@
|
||||
*/
|
||||
# define u3a_page 12
|
||||
|
||||
/* u3a_pages: number of pages in memory.
|
||||
/* u3a_pages: maximum number of pages in memory.
|
||||
*/
|
||||
# define u3a_pages (1 << (u3a_bits - u3a_page))
|
||||
|
||||
/* u3a_words: number of words in memory.
|
||||
/* u3a_words: maximum number of words in memory.
|
||||
*/
|
||||
# define u3a_words (1 << u3a_bits)
|
||||
|
||||
/* u3a_bytes: number of bytes in memory.
|
||||
/* u3a_bytes: maximum number of bytes in memory.
|
||||
*/
|
||||
# define u3a_bytes (sizeof(c3_w) * u3a_words)
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
typedef struct _u3e_pool {
|
||||
c3_c* dir_c; // path to
|
||||
c3_w dit_w[u3a_pages >> 5]; // touched since last save
|
||||
c3_w pag_w; // number of pages (<= u3a_pages)
|
||||
u3e_image nor_u; // north segment
|
||||
u3e_image sou_u; // south segment
|
||||
} u3e_pool;
|
||||
|
@ -9,6 +9,8 @@
|
||||
u3_noun who; // single identity
|
||||
c3_c* dir_c; // execution directory (pier)
|
||||
c3_w wag_w; // flags (both ways)
|
||||
size_t byt_i; // loom byte-length (<= u3a_bytes)
|
||||
size_t wor_i; // loom word-length (<= u3a_words)
|
||||
void (*stderr_log_f)(c3_c*); // errors from c code
|
||||
void (*slog_f)(u3_noun); // function pointer for slog
|
||||
void (*sign_hold_f)(void); // suspend system signal regime
|
||||
|
@ -136,9 +136,9 @@ u3e_check(c3_c* cap_c)
|
||||
sum_w += mug_w;
|
||||
}
|
||||
for ( i_w = 0; i_w < sou_w; i_w++ ) {
|
||||
mug_w = _ce_check_page((u3a_pages - (i_w + 1)));
|
||||
mug_w = _ce_check_page((u3P.pag_w - (i_w + 1)));
|
||||
if ( strcmp(cap_c, "boot") ) {
|
||||
c3_assert(mug_w == u3K.mug_w[(u3a_pages - (i_w + 1))]);
|
||||
c3_assert(mug_w == u3K.mug_w[(u3P.pag_w - (i_w + 1))]);
|
||||
}
|
||||
sum_w += mug_w;
|
||||
}
|
||||
@ -195,7 +195,7 @@ _ce_center_guard_page(void)
|
||||
{
|
||||
u3p(c3_w) bot_p, top_p;
|
||||
if ( !u3R ) {
|
||||
top_p = u3a_outa(u3_Loom + u3a_words);
|
||||
top_p = u3a_outa(u3_Loom + u3C.wor_i);
|
||||
bot_p = u3a_outa(u3_Loom);
|
||||
}
|
||||
else if ( c3y == u3a_is_north(u3R) ) {
|
||||
@ -255,9 +255,9 @@ u3e_fault(void* adr_v, c3_i ser_i)
|
||||
|
||||
c3_w* adr_w = (c3_w*) adr_v;
|
||||
|
||||
if ( (adr_w < u3_Loom) || (adr_w >= (u3_Loom + u3a_words)) ) {
|
||||
if ( (adr_w < u3_Loom) || (adr_w >= (u3_Loom + u3C.wor_i)) ) {
|
||||
fprintf(stderr, "address %p out of loom!\r\n", adr_w);
|
||||
fprintf(stderr, "loom: [%p : %p)\r\n", u3_Loom, u3_Loom + u3a_words);
|
||||
fprintf(stderr, "loom: [%p : %p)\r\n", u3_Loom, u3_Loom + u3C.wor_i);
|
||||
c3_assert(0);
|
||||
return 0;
|
||||
}
|
||||
@ -629,7 +629,7 @@ _ce_patch_compose(void)
|
||||
pgs_w = _ce_patch_count_page(i_w, pgs_w);
|
||||
}
|
||||
for ( i_w = 0; i_w < sou_w; i_w++ ) {
|
||||
pgs_w = _ce_patch_count_page((u3a_pages - (i_w + 1)), pgs_w);
|
||||
pgs_w = _ce_patch_count_page((u3P.pag_w - (i_w + 1)), pgs_w);
|
||||
}
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ _ce_patch_compose(void)
|
||||
pgc_w = _ce_patch_save_page(pat_u, i_w, pgc_w);
|
||||
}
|
||||
for ( i_w = 0; i_w < sou_w; i_w++ ) {
|
||||
pgc_w = _ce_patch_save_page(pat_u, (u3a_pages - (i_w + 1)), pgc_w);
|
||||
pgc_w = _ce_patch_save_page(pat_u, (u3P.pag_w - (i_w + 1)), pgc_w);
|
||||
}
|
||||
|
||||
pat_u->con_u->nor_w = nor_w;
|
||||
@ -745,7 +745,7 @@ _ce_patch_apply(u3_ce_patch* pat_u)
|
||||
}
|
||||
else {
|
||||
fid_i = u3P.sou_u.fid_i;
|
||||
off_w = (u3a_pages - (pag_w + 1));
|
||||
off_w = (u3P.pag_w - (pag_w + 1));
|
||||
}
|
||||
|
||||
if ( -1 == read(pat_u->mem_i, mem_w, pag_siz_i) ) {
|
||||
@ -983,7 +983,7 @@ u3e_save(void)
|
||||
pag_wiz_i);
|
||||
|
||||
_ce_image_fine(&u3P.sou_u,
|
||||
(u3_Loom + (1 << u3a_bits) - pag_wiz_i),
|
||||
(u3_Loom + u3C.wor_i) - pag_wiz_i,
|
||||
-(ssize_t)pag_wiz_i);
|
||||
|
||||
c3_assert(u3P.nor_u.pgs_w == u3K.nor_w);
|
||||
@ -1011,6 +1011,7 @@ u3e_live(c3_o nuu_o, c3_c* dir_c)
|
||||
u3P.dir_c = dir_c;
|
||||
u3P.nor_u.nam_c = "north";
|
||||
u3P.sou_u.nam_c = "south";
|
||||
u3P.pag_w = u3C.wor_i >> u3a_page;
|
||||
|
||||
// XX review dryrun requirements, enable or remove
|
||||
//
|
||||
@ -1053,7 +1054,7 @@ u3e_live(c3_o nuu_o, c3_c* dir_c)
|
||||
pag_wiz_i);
|
||||
|
||||
_ce_image_blit(&u3P.sou_u,
|
||||
(u3_Loom + (1 << u3a_bits) - pag_wiz_i),
|
||||
(u3_Loom + u3C.wor_i) - pag_wiz_i,
|
||||
-(ssize_t)pag_wiz_i);
|
||||
|
||||
u3l_log("boot: protected loom\r\n");
|
||||
@ -1082,7 +1083,7 @@ u3e_yolo(void)
|
||||
{
|
||||
// NB: u3e_save() will reinstate protection flags
|
||||
//
|
||||
if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, (PROT_READ | PROT_WRITE)) ) {
|
||||
if ( 0 != mprotect((void *)u3_Loom, u3C.byt_i, (PROT_READ | PROT_WRITE)) ) {
|
||||
return c3n;
|
||||
}
|
||||
|
||||
@ -1100,6 +1101,8 @@ u3e_foul(void)
|
||||
void
|
||||
u3e_init(void)
|
||||
{
|
||||
u3P.pag_w = u3C.wor_i >> u3a_page;
|
||||
|
||||
#ifdef U3_GUARD_PAGE
|
||||
_ce_center_guard_page();
|
||||
#endif
|
||||
|
@ -553,7 +553,7 @@ _pave_home(void)
|
||||
{
|
||||
c3_w* mem_w = u3_Loom + 1;
|
||||
c3_w siz_w = c3_wiseof(u3v_home);
|
||||
c3_w len_w = u3a_words - 1;
|
||||
c3_w len_w = u3C.wor_i - 1;
|
||||
|
||||
u3H = (void *)_pave_north(mem_w, siz_w, len_w);
|
||||
u3H->ver_w = u3v_version;
|
||||
@ -574,7 +574,7 @@ _find_home(void)
|
||||
//
|
||||
c3_w* mem_w = u3_Loom + 1;
|
||||
c3_w siz_w = c3_wiseof(u3v_home);
|
||||
c3_w len_w = u3a_words - 1;
|
||||
c3_w len_w = u3C.wor_i - 1;
|
||||
|
||||
{
|
||||
c3_w ver_w = *((mem_w + len_w) - 1);
|
||||
@ -594,7 +594,7 @@ _find_home(void)
|
||||
// this looks risky, but there are no legitimate scenarios
|
||||
// where it's wrong
|
||||
//
|
||||
u3R->cap_p = u3R->mat_p = u3a_words - c3_wiseof(*u3H);
|
||||
u3R->cap_p = u3R->mat_p = u3C.wor_i - c3_wiseof(*u3H);
|
||||
}
|
||||
|
||||
/* u3m_pave(): instantiate or activate image.
|
||||
@ -1830,6 +1830,8 @@ u3m_init(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
u3C.byt_i = len_i;
|
||||
u3C.wor_i = len_i >> 2;
|
||||
u3l_log("loom: mapped %zuMB\r\n", len_i >> 20);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user