diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.c | 8 | ||||
| -rw-r--r-- | src/core/genome.h | 35 | ||||
| -rw-r--r-- | src/core/memmap.h | 34 |
3 files changed, 36 insertions, 41 deletions
diff --git a/src/core/core.c b/src/core/core.c index 3a1d0ca..dc50644 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -58,13 +58,7 @@ #include <sys/mman.h> #include <ucontext.h> #endif -#ifdef USE_LSP_GENOME -#include "lsp_genome.h" -#elif defined(GENOME_H) -#include GENOME_H -#else #include "genome.h" -#endif #include "memmap.h" #include "fops.h" #include "bops.h" @@ -6208,7 +6202,7 @@ int main(int argc, char **argv) fprintf(stderr, "zy: genome does not fit\n"); return 1; } - memcpy(m + GORG, genome, sizeof genome); + for (int g = 0; g < GLEN; g++) m[GORG + g] = genome_word(g); m[ZFP + 6] = FBOT; m[ZFP + 7] = FTOP; m[ZFP + 8] = 1024; #ifdef ZYJIT { diff --git a/src/core/genome.h b/src/core/genome.h new file mode 100644 index 0000000..9d0ff96 --- /dev/null +++ b/src/core/genome.h @@ -0,0 +1,35 @@ +/* the genome: the image a core boots, embedded into the core when it is + compiled. an image is a file of little-endian 64-bit words placed at GORG, + as written by zc0 or by src/tools/build.zc and checked by mkgenome. the + build keeps every image in build/, never in the tree. + + GENOME_FILE names the image. it defaults to "genome.bin" (or + "lsp_genome.bin" with USE_LSP_GENOME) and is found next to this header, + then in the directories given with --embed-dir, so that option selects + which image a core carries. the file needs a compiler with c23 + #embed (clang 19 or gcc 15 and later). + + no libc here: the microcore includes this on bare metal. */ +#ifndef GENOME_H_INCLUDED +#define GENOME_H_INCLUDED +#include <stdint.h> +#ifndef GENOME_FILE +#ifdef USE_LSP_GENOME +#define GENOME_FILE "lsp_genome.bin" +#else +#define GENOME_FILE "genome.bin" +#endif +#endif +static const unsigned char genome_image[] = { +#embed GENOME_FILE +}; +/* the image's length in words */ +#define GLEN ((int)(sizeof genome_image / 8)) +/* word i of the image, independent of the host's byte order */ +static int64_t genome_word(int i) +{ + const unsigned char *b = genome_image + (long)i * 8; + return (int64_t)((uint64_t)b[0] | (uint64_t)b[1] << 8 | (uint64_t)b[2] << 16 | (uint64_t)b[3] << 24 + | (uint64_t)b[4] << 32 | (uint64_t)b[5] << 40 | (uint64_t)b[6] << 48 | (uint64_t)b[7] << 56); +} +#endif diff --git a/src/core/memmap.h b/src/core/memmap.h deleted file mode 100644 index cc768d4..0000000 --- a/src/core/memmap.h +++ /dev/null @@ -1,34 +0,0 @@ -/* generated by src/tools/genmap for the default profile. do not edit. */ -#ifndef MEMMAP_H -#define MEMMAP_H -#define PW 0x1D5000 -#define CODE_END 0x80000 -#define HEAP_LO 0x1D5000 -#define HEAP_HI 0x235000 -#define HEAP_GROW 1 -#ifndef MW -#define MW 0x8000000 -#endif -#if MW < HEAP_HI -#error MW is below the end of the initial heap -#endif -#define ZFP 0x90000 -#ifdef GORG -#if GORG != 0x114100 -#error genome GORG does not match this map -#endif -#else -#define GORG 0x114100 -#endif -#define FBOT 0x174100 -#define FTOP 0x1B4100 -#define RS0 0x1B4100 -#define MARK0 0x1C4100 -#define MARKN 0x8000 -#define DSLO 0x1CC100 -#define DSHI 0x1D4FF0 -#define DS0 DSHI -#define SYSGATE (ZFP + 2) -#define DSLIM (DSLO + 1100) -#define RSLIM (MARK0 - 8) -#endif |
