From c70ced473843e332ea38820bf3cd9a19c4a1e81e Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Sat, 13 Jan 2024 11:18:05 +0800 Subject: [PATCH] =?UTF-8?q?>=20compile=20NEMU=20ysyx=5F22040000=20?= =?UTF-8?q?=E6=9D=8E=E5=BF=83=E6=9D=A8=20Linux=20calcite=206.1.71=20#1-Nix?= =?UTF-8?q?OS=20SMP=20PREEMPT=5FDYNAMIC=20Fri=20Jan=20=205=2014:18:41=20UT?= =?UTF-8?q?C=202024=20x86=5F64=20GNU/Linux=20=2011:18:05=20=20up=20=20=200?= =?UTF-8?q?:12,=20=202=20users,=20=20load=20average:=200.53,=200.27,=200.1?= =?UTF-8?q?4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nemu/.config.old | 74 ------------------- nemu/.gitignore | 1 + nemu/src/monitor/sdb/addrexp.y | 5 +- nemu/src/monitor/sdb/expr.c | 129 --------------------------------- nemu/src/monitor/sdb/sdb.h | 2 - nemu/test | Bin 15688 -> 0 bytes nemu/test.c | 8 -- 7 files changed, 5 insertions(+), 214 deletions(-) delete mode 100644 nemu/.config.old delete mode 100644 nemu/src/monitor/sdb/expr.c delete mode 100755 nemu/test delete mode 100644 nemu/test.c diff --git a/nemu/.config.old b/nemu/.config.old deleted file mode 100644 index 1a17e6e..0000000 --- a/nemu/.config.old +++ /dev/null @@ -1,74 +0,0 @@ -# -# Automatically generated file; DO NOT EDIT. -# NEMU Configuration Menu -# -# CONFIG_ISA_x86 is not set -# CONFIG_ISA_mips32 is not set -CONFIG_ISA_riscv=y -# CONFIG_ISA_loongarch32r is not set -CONFIG_ISA="riscv32" - -# -# ISA-dependent Options for riscv -# -# CONFIG_RV64 is not set -# CONFIG_RVE is not set -# end of ISA-dependent Options for riscv - -CONFIG_ENGINE_INTERPRETER=y -CONFIG_ENGINE="interpreter" -CONFIG_MODE_SYSTEM=y -CONFIG_TARGET_NATIVE_ELF=y -# CONFIG_TARGET_SHARE is not set -# CONFIG_TARGET_AM is not set - -# -# Build Options -# -CONFIG_CC_GCC=y -# CONFIG_CC_GPP is not set -# CONFIG_CC_CLANG is not set -CONFIG_CC="gcc" -# CONFIG_CC_O0 is not set -# CONFIG_CC_O1 is not set -CONFIG_CC_O2=y -# CONFIG_CC_O3 is not set -CONFIG_CC_OPT="-O2" -# CONFIG_CC_LTO is not set -# CONFIG_CC_DEBUG is not set -# CONFIG_CC_ASAN is not set -# end of Build Options - -# -# Testing and Debugging -# -CONFIG_TRACE=y -CONFIG_TRACE_START=0 -CONFIG_TRACE_END=10000 -CONFIG_ITRACE=y -CONFIG_ITRACE_COND="true" -# CONFIG_DIFFTEST is not set -CONFIG_DIFFTEST_REF_PATH="none" -CONFIG_DIFFTEST_REF_NAME="none" -# end of Testing and Debugging - -# -# Memory Configuration -# -CONFIG_MBASE=0x80000000 -CONFIG_MSIZE=0x8000000 -CONFIG_PC_RESET_OFFSET=0 -# CONFIG_PMEM_MALLOC is not set -CONFIG_PMEM_GARRAY=y -CONFIG_MEM_RANDOM=y -# end of Memory Configuration - -# CONFIG_DEVICE is not set - -# -# Miscellaneous -# -CONFIG_TIMER_GETTIMEOFDAY=y -# CONFIG_TIMER_CLOCK_GETTIME is not set -CONFIG_RT_CHECK=y -# end of Miscellaneous diff --git a/nemu/.gitignore b/nemu/.gitignore index 7faa353..77fe490 100644 --- a/nemu/.gitignore +++ b/nemu/.gitignore @@ -5,6 +5,7 @@ build/ .cache/ .direnv/ .config +.config.old .envrc compile_commands.json diff --git a/nemu/src/monitor/sdb/addrexp.y b/nemu/src/monitor/sdb/addrexp.y index 6aadc7a..3040872 100644 --- a/nemu/src/monitor/sdb/addrexp.y +++ b/nemu/src/monitor/sdb/addrexp.y @@ -1,3 +1,6 @@ +%code requires { + #include +} %{ #include #include @@ -10,7 +13,7 @@ %token NUMBER HEX_NUMBER %start input -%define api.value.type { uint32_t } +%define api.value.type { word_t } %parse-param { uint32_t *result } %left '-' '+' %left '*' '/' diff --git a/nemu/src/monitor/sdb/expr.c b/nemu/src/monitor/sdb/expr.c deleted file mode 100644 index 45d6483..0000000 --- a/nemu/src/monitor/sdb/expr.c +++ /dev/null @@ -1,129 +0,0 @@ -/*************************************************************************************** -* Copyright (c) 2014-2022 Zihao Yu, Nanjing University -* -* NEMU is licensed under Mulan PSL v2. -* You can use this software according to the terms and conditions of the Mulan PSL v2. -* You may obtain a copy of Mulan PSL v2 at: -* http://license.coscl.org.cn/MulanPSL2 -* -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -* -* See the Mulan PSL v2 for more details. -***************************************************************************************/ - -#include - -/* We use the POSIX regex functions to process regular expressions. - * Type 'man regex' for more information about POSIX regex functions. - */ -#include - -enum { - TK_NOTYPE = 256, TK_EQ, TK_NUMBER, - LEX_GROUP_OPERATOR, LEX_GROUP_DIGIT -}; - -static struct rule { - const char *regex; - int token_type; -} rules[] = { - {"[ \t]+", TK_NOTYPE}, - {"==", TK_EQ}, - {"[0-9]+", LEX_GROUP_DIGIT}, - {"[\\+-*/()", LEX_GROUP_OPERATOR}, -}; - -#define NR_REGEX ARRLEN(rules) - -static regex_t re[NR_REGEX] = {}; - -/* Rules are used for many times. - * Therefore we compile them only once before any usage. - */ -void init_regex() { - int i; - char error_msg[128]; - int ret; - - for (i = 0; i < NR_REGEX; i ++) { - ret = regcomp(&re[i], rules[i].regex, REG_EXTENDED); - if (ret != 0) { - regerror(ret, &re[i], error_msg, 128); - panic("regex compilation failed: %s\n%s", error_msg, rules[i].regex); - } - } -} - -typedef struct token { - int type; - char str[32]; -} Token; - -static Token tokens[32] __attribute__((used)) = {}; -static int nr_token __attribute__((used)) = 0; - -static bool make_token(char *e) { - int position = 0; - int i; - regmatch_t pmatch; - - nr_token = 0; - - while (e[position] != '\0') { - /* Try all rules one by one. */ - for (i = 0; i < NR_REGEX; i ++) { - if (regexec(&re[i], e + position, 1, &pmatch, 0) == 0 && pmatch.rm_so == 0) { - char *substr_start = e + position; - int substr_len = pmatch.rm_eo; - - Log("match rules[%d] = \"%s\" at position %d with len %d: %.*s", - i, rules[i].regex, position, substr_len, substr_len, substr_start); - - position += substr_len; - - /* TODO: Now a new token is recognized with rules[i]. Add codes - * to record the token in the array `tokens'. For certain types - * of tokens, some extra actions should be performed. - */ - - switch (rules[i].token_type) { - case LEX_GROUP_OPERATOR: - tokens[nr_token].type = *substr_start; - tokens[nr_token].str[0] = '\0'; - nr_token++; - break; - case LEX_GROUP_DIGIT: - tokens[nr_token].type = TK_NUMBER; - nr_token++; - break; - case TK_NOTYPE: break; - default: TODO(); - } - - break; - } - } - - if (i == NR_REGEX) { - printf("no match at position %d\n%s\n%*.s^\n", position, e, position, ""); - return false; - } - } - - return true; -} - - -word_t expr(char *e, bool *success) { - if (!make_token(e)) { - *success = false; - return 0; - } - - /* TODO: Insert codes to evaluate the expression. */ - TODO(); - - return 0; -} diff --git a/nemu/src/monitor/sdb/sdb.h b/nemu/src/monitor/sdb/sdb.h index d2800d1..e94846c 100644 --- a/nemu/src/monitor/sdb/sdb.h +++ b/nemu/src/monitor/sdb/sdb.h @@ -18,6 +18,4 @@ #include -word_t expr(char *e, bool *success); - #endif diff --git a/nemu/test b/nemu/test deleted file mode 100755 index 74295cc37644f48114e51d564687c5976f4d25c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15688 zcmeHOU2Ggz6~4Pph(lX@oiwSNw9TlrRjInWwqv_aOUU>yS)=@sq$sE~)A8=uyLfkY zwL2T{`URI1q<}y{LMY;;d8~vg8B|pkLey2NR!AVZf`>jDL{KV9Nd;6 zaMh{^AyspvnRCz2ckaFC-kG_xd*>UIM-RtiF$IdNFDjNQ2~(^5vr?VIS`^)gxx`A}i@1xFZ#S2XVSS!;hm3(=Q1Bg{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g(y1b;g`2^;ptldV>^^0u2RI?9?l zL0-9nYt?H`j)J&!$`!4uQ!Hm~&*2bWA!}6%9eV#{&zEg0j6_s+!o|Bq&>#0h$Tyd&iQ&gj4Q%N3TZOhxWyh`Po zF2(b?SM@FDoocO6b~gwX*{CZv1Ef?bdMc&cl=7Sgm3e5%R@UiDIe8h(e2%b?e1t!$ zJ_2P5Y?lgIsA);}Wy>MVUEY zfBb9)z9M*h&t#GAyJ(p8?Rm3cv-JB&2LXfc@S`<9iSK;=fNefiqrUH-k*-{9P z`q3Wr|2e^rNx(H}|C-?8$N1fJgz^4!eSLh}_j7tQF=1WoOMY8XW`2`_0~Z}^TA-)ka|z+oJJPgu?$@L12Srb$WE z=d<=1czd!&&~|}pc6Prn{S+06F(lF&baVXnAs_I8;K0K8e*=JQ B(g6Sf diff --git a/nemu/test.c b/nemu/test.c deleted file mode 100644 index caaed92..0000000 --- a/nemu/test.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -int main() { - uint32_t result = (0xdU) * (31U / ((((0x45U)) - 75U)) * (0x41U) + 53U / (0xaU) - (0x50U)); - printf("%u", result); - return 0; -} -