genprofz.c
来自「ESS3890+SL原代码(1*16内存)」· C语言 代码 · 共 271 行
C
271 行
/* Copyright 1996, ESS Technology, Inc. *//* SCCSID @(#)genprofz.c 4.5 06/15/04 *//* Based on SVCD genprof.c 1.1 8/2/99 *//* * $Log$ *//* * This program generates the profile for making a ROM image. * * Usage: genprof rom_size * rom_size: 128/256/512/1024/2048K ROM * */#include <stdio.h>#include <time.h>#include <sys/time.h>#define FAKE/* undef GBLDEF used in memmap.h for the purpose of generating profile */#define GBLDEF(name, value) extern name#include "memmap.h"unsigned long stack_top = VCD_VBV_start * 4;unsigned long heap_start = DISP_start * 4;int romsize; /* ROM size may be different */int organization = 1;/* * We only care about bank 3 address (1C000000). We'll set all "high-order" * bits to 1 for ROM emulator support. Even though our chips only have * 22 address pins (A21), I'll reserve all the way to A23. I'll leave * A24 and A25 empty for carries. * * Address is set such that we just have enough bits empty for the * desired ROM size. */long startaddr[] = { 0x1cfe0000, /* 128K ROM (0x20000) */ 0x1cfc0000, /* 256K ROM (0x40000) */ 0x1cf80000, /* 512K ROM (0x80000) */ 0x1cf00000, /* 1024K ROM (0x100000) */ 0x1ce00000, /* 2048K ROM (0x200000) */};long lastaddr[5];long getVersion(void);int main(int argc, char **argv){ int index; long tmp; if ((argc != 2) || (sscanf(argv[1], "%d", &romsize) != 1)) { fprintf(stderr, "Usage: %s rom_size\n", argv[0]); return 1; } /* Compute the last address based on the starting address */ tmp = 0x20000; /* 256K */ for (index = 0; index < 5; index++) { lastaddr[index] = startaddr[index] + tmp; tmp <<= 1; } /* Translate ROM size to index into the arrays */ switch(romsize) { case 128: index = 0; break; case 256: index = 1; break; case 512: index = 2; break; case 1024: index = 3; break; case 2048: index = 4; break; default: fprintf(stderr, "Usage: %s {128|256|512|1024|2048}\n", argv[0]); exit(1); } /* explanations */ fprintf(stdout, "# GENERATED AUTOMATICALLY! DON'T MODIFY IT UNLESS YOU KNOW THE SECRETS!!\n"); fprintf(stdout, "\n#####################################\n"); fprintf(stdout, "### Profile for making bank30.rom ###\n"); fprintf(stdout, "#####################################\n\n"); fprintf(stdout, "# The format of content entries consists of three fields:\n"); fprintf(stdout, "# (1) type(file/data/text). data/text marks DATA/TEXT segment,\n"); fprintf(stdout, "# file marks a pure data file.\n"); fprintf(stdout, "# (2) filename\n"); fprintf(stdout, "# (3) cache/noncache(default cache)\n\n"); /* content */ fprintf(stdout, "[content]\n"); fprintf(stdout, "text demux.rom\n"); fprintf(stdout, "data demux.rom\n");#ifdef CODE_IN_ROM fprintf(stdout, "text rdsa.rom noncache\n"); fprintf(stdout, "data rdsa.rom\n");#endif#ifdef XSEG1_ON_FLY fprintf(stdout, "text xtra_s1.rom\n"); fprintf(stdout, "data xtra_s1.rom\n");#endif#ifdef XSEG2_ON_FLY fprintf(stdout, "text xtra_s2.rom\n"); fprintf(stdout, "data xtra_s2.rom\n");#endif#ifdef XSEG3_ON_FLY fprintf(stdout, "text xtra_s3.rom\n"); fprintf(stdout, "data xtra_s3.rom\n");#endif#ifdef XSEG4_ON_FLY fprintf(stdout, "text xtra_s4.rom\n"); fprintf(stdout, "data xtra_s4.rom\n");#endif fprintf(stdout, "file const.dat\n");#ifdef COMPRESS fprintf(stdout, "file decomp.txt\n"); fprintf(stdout, "file decomp.dat\n");#endif COMPRESS /* boot code */ fprintf(stdout, "\n\n# bootcode specifies the name of startup code\n\n"); fprintf(stdout, "[bootcode]\n"); fprintf(stdout, "boot\n\n"); /* compress */ fprintf(stdout, "# compress lists the text/data/file to be compressed\n\n"); fprintf(stdout, "[compress]\n");#ifdef COMPRESS fprintf(stdout, "text demux.rom\n");#endif COMPRESS#ifdef XSEG1_ON_FLY fprintf(stdout, "data xtra_s1.rom\n"); fprintf(stdout, "text xtra_s1.rom\n");#endif XSEG1_ON_FLY#ifdef XSEG2_ON_FLY fprintf(stdout, "data xtra_s2.rom\n"); fprintf(stdout, "text xtra_s2.rom\n");#endif XSEG2_ON_FLY#ifdef XSEG3_ON_FLY fprintf(stdout, "data xtra_s3.rom\n"); fprintf(stdout, "text xtra_s3.rom\n");#endif XSEG3_ON_FLY#ifdef XSEG4_ON_FLY fprintf(stdout, "data xtra_s4.rom\n"); fprintf(stdout, "text xtra_s4.rom\n");#endif XSEG4_ON_FLY fprintf(stdout, "\n"); /* command blocks */ fprintf(stdout, "# cmdblock lists the commands to be executed during startup.\n"); fprintf(stdout, "# The commands will be parsed by mvdrom.\n"); fprintf(stdout, "# After being parsed, each command occupies 16bytes in ROM image.\n"); fprintf(stdout, "# The format is : command type, source address, destination address, size.\n\n"); fprintf(stdout, "[cmdblock]\n");#ifdef COMPRESS fprintf(stdout, "copy demux.rom data\n"); fprintf(stdout, "clear demux.rom bss\n"); fprintf(stdout, "\n"); fprintf(stdout,"copy decomp.dat %lx\n",SHARE_start<<2); fprintf(stdout,"set4 demux.rom text\n"); fprintf(stdout,"set5 %x\n",CODE_start<<2); fprintf(stdout,"set25\n"); fprintf(stdout,"set29 %lx\n",stack_top); fprintf(stdout,"set19 %08lx\n", heap_start); fprintf(stdout,"set24 decomp.txt\n"); fprintf(stdout,"jsr decomp.txt\n"); fprintf(stdout, "copy demux.rom data\n"); fprintf(stdout, "clear demux.rom bss\n"); fprintf(stdout, "set23 demux.rom %x\n",CODE_start<<2); fprintf(stdout, "jump demux.rom START\n\n");#else fprintf(stdout, "copy demux.rom data\n"); fprintf(stdout, "clear demux.rom bss\n"); fprintf(stdout, "copy rdsa.rom data\n"); fprintf(stdout, "clear rdsa.rom bss\n"); fprintf(stdout, "set23 demux.rom text\n"); fprintf(stdout, "set24 rdsa.rom text\n"); fprintf(stdout, "jump rdsa.rom START\n\n");#endif COMPRESS /* variables */ fprintf(stdout, "[variables]\n"); fprintf(stdout, "_vcx_romdatastart const.dat\n" );#ifdef XSEG1_ON_FLY fprintf(stdout, "_xtra_s1_compress_data_start xtra_s1.rom data\n"); fprintf(stdout, "_xtra_s1_compress_text_start xtra_s1.rom text\n" );#endif XSEG1_ON_FLY#ifdef XSEG2_ON_FLY fprintf(stdout, "_xtra_s2_compress_data_start xtra_s2.rom data\n"); fprintf(stdout, "_xtra_s2_compress_text_start xtra_s2.rom text\n" );#endif XSEG2_ON_FLY#ifdef XSEG3_ON_FLY fprintf(stdout, "_xtra_s3_compress_data_start xtra_s3.rom data\n"); fprintf(stdout, "_xtra_s3_compress_text_start xtra_s3.rom text\n" );#endif XSEG3_ON_FLY#ifdef XSEG4_ON_FLY fprintf(stdout, "_xtra_s4_compress_data_start xtra_s4.rom data\n"); fprintf(stdout, "_xtra_s4_compress_text_start xtra_s4.rom text\n" );#endif XSEG4_ON_FLY#ifdef DEMUX_ON_FLY fprintf(stdout, "_demux_rom_start demux.rom text\n");#endif fprintf(stdout, "\n"); /* rom version */ fprintf(stdout, "# rom version is the date on which the ROM image is generated.\n"); fprintf(stdout, "[romversion]\n%08lx\n\n", getVersion()); /* rom size */ fprintf(stdout, "# rom size is the amount of memory (in Kilobytes) of one EPROM bank.\n"); fprintf(stdout, "[romsize]\n%dk\n\n", romsize); /* divisor */ fprintf(stdout, "# divisor is reserved for further extension.\n"); fprintf(stdout, "[divisor]\n\n"); /* status */ fprintf(stdout, "# stat is reserved for further extension.\n"); fprintf(stdout, "[stat]\n\n"); /* organization */ fprintf(stdout, "# organization is the number of EPROM banks. For now, only 1.\n"); fprintf(stdout, "[organization]\n%d\n\n", organization); /* last address */ fprintf(stdout, "[lastaddr]\n%lx\n\n", lastaddr[index]); /* output */ fprintf(stdout, "# output is the file name of ROM image, e.g. bank30.rom\n\n"); fprintf(stdout, "[output]\nbank30.rom\n\n"); return 0;}long getVersion(void){ long result = 0; char *ptr, version[20]; time_t tmp; /* Get today's time */ time(&tmp); strftime(version, 20, "%D", localtime(&tmp)); ptr = version; while (*ptr) { if ((*ptr >= '0') && (*ptr <= '9')) result = (result << 4) | (*ptr - '0'); ptr++; } return(result);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?