diff --git a/user/Cargo.lock b/user/Cargo.lock index 49754d9..c45f91e 100644 --- a/user/Cargo.lock +++ b/user/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "linked_list_allocator" version = "0.6.3" diff --git a/user/Makefile b/user/Makefile index 7f42564..131199a 100644 --- a/user/Makefile +++ b/user/Makefile @@ -1,4 +1,4 @@ -# arch = {riscv32, x86_64, aarch64} +# arch = {riscv32, riscv64, x86_64, aarch64} # mode = {debug, release} arch ?= riscv32 mode ?= debug @@ -24,12 +24,7 @@ endif .PHONY: all clean build-rust build-c build mksfs sfsimg -# not support riscv64 now -ifeq ($(arch), riscv64) -all: -else all: $(sfsimg) -endif build-rust: @echo Building user rust programs diff --git a/user/hand/.gitignore b/user/hand/.gitignore deleted file mode 100644 index a979526..0000000 --- a/user/hand/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -output/ -*.img diff --git a/user/hand/build_img b/user/hand/build_img deleted file mode 100755 index 7a1574d..0000000 --- a/user/hand/build_img +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -ARCH=riscv64 - -CC=${ARCH}-unknown-elf-gcc -CFLAGS="-nostartfiles -nostdlib -nodefaultlibs -o output/a.out -T ${ARCH}.ld -fno-builtin" -if ! [[ -d output ]] -then - mkdir output -fi - -#CFLAGS="${CFLAGS} -DRISCV_QEMU" - -${CC} ${CFLAGS} test.c -mksfs zip output ./user-${ARCH}.img diff --git a/user/hand/riscv32.ld b/user/hand/riscv32.ld deleted file mode 100644 index e4052bc..0000000 --- a/user/hand/riscv32.ld +++ /dev/null @@ -1,43 +0,0 @@ -OUTPUT_ARCH(riscv) -ENTRY(_start) - -SECTIONS { - /* Load programs at this address: "." means the current address */ - . = 0x00800020; - - .text : { - *(.text .stub .text.* .gnu.linkonce.t.*) - } - - PROVIDE(etext = .); /* Define the 'etext' symbol to this value */ - - .rodata : { - *(.rodata .rodata.* .gnu.linkonce.r.*) - } - - /* Adjust the address for the data segment to the next page */ - . = ALIGN(0x1000); - - /* The data segment */ - .data : { - *(.data) - *(.data.*) - } - - .sdata : { - *(.sdata) - *(.sdata.*) - } - - PROVIDE(edata = .); - - .bss : { - *(.bss) - } - - PROVIDE(end = .); - - /DISCARD/ : { - *(.eh_frame .note.GNU-stack .comment) - } -} diff --git a/user/hand/riscv64.ld b/user/hand/riscv64.ld deleted file mode 100644 index d901f84..0000000 --- a/user/hand/riscv64.ld +++ /dev/null @@ -1,43 +0,0 @@ -OUTPUT_ARCH(riscv) -ENTRY(_start) - -SECTIONS { - /* Load programs at this address: "." means the current address */ - . = 0x800020; - - .text : { - *(.text .stub .text.* .gnu.linkonce.t.*) - } - - PROVIDE(etext = .); /* Define the 'etext' symbol to this value */ - - .rodata : { - *(.rodata .rodata.* .gnu.linkonce.r.*) - } - - /* Adjust the address for the data segment to the next page */ - . = ALIGN(0x1000); - - /* The data segment */ - .data : { - *(.data) - *(.data.*) - } - - .sdata : { - *(.sdata) - *(.sdata.*) - } - - PROVIDE(edata = .); - - .bss : { - *(.bss) - } - - PROVIDE(end = .); - - /DISCARD/ : { - *(.eh_frame .note.GNU-stack .comment) - } -} diff --git a/user/hand/test.c b/user/hand/test.c deleted file mode 100644 index 98db558..0000000 --- a/user/hand/test.c +++ /dev/null @@ -1,87 +0,0 @@ -#ifdef RISCV_QEMU -# define SYS_write 64 -# define SYS_exit 93 -long syscall(long a0, long a1, long a2, long a3, long a4, long a5, long a6) { - register long _0 __asm__("a7") = a0; - register long _1 __asm__("a0") = a1; - register long _2 __asm__("a1") = a2; - register long _3 __asm__("a2") = a3; - register long _4 __asm__("a3") = a4; - register long _5 __asm__("a4") = a5; - register long _6 __asm__("a5") = a6; - __asm__ __volatile__("ecall":::); - return _1; -} - -#else -# define SYS_write 103 -# define SYS_exit 1 -# define SYS_fork 2 -# define SYS_putc 30 -# define SYS_getpid 18 -# define SYS_sleep 11 - -long syscall(long a0, long a1, long a2, long a3, long a4, long a5, long a6) { - register long _0 __asm__("x10") = a0; - register long _1 __asm__("x11") = a1; - register long _2 __asm__("x12") = a2; - register long _3 __asm__("x13") = a3; - register long _4 __asm__("x14") = a4; - register long _5 __asm__("x15") = a5; - register long _6 __asm__("x16") = a6; - __asm__ __volatile__("ecall":::); - return _0; -} -#endif - -const char* welcome_msg = "hello world!\n"; -const char* hexch = "0123456789ABCDEF"; - -void putc(char c) { - syscall(SYS_putc, c, 0, 0, 0, 0, 0); -} - -void putstr(const char* s) { - for (; *s; s++) - syscall(SYS_putc, *s, 0, 0, 0, 0, 0); -} - -void putint_hex(long v) { - char ch[18]; - ch[16] = 'H'; - ch[17] = 0; - for (int i = 15; i >= 0; i--) { - ch[i] = hexch[v & 15]; - v >>= 4; - } - putstr(ch); -} - -void _start() { - putstr(welcome_msg); - putc('\n'); - - putstr("my pid is "); - long v = syscall(SYS_getpid, 0, 0, 0, 0, 0, 0); - putint_hex(v); - putc('\n'); - - long v1 = syscall(SYS_fork, 0, 0, 0, 0, 0, 0); - putstr("fork returned: "); - putint_hex(v1); - putc('\n'); - if (v1 != 0) { - putstr("parent sleeping"); - putc('\n'); - syscall(SYS_sleep, 200, 0, 0, 0, 0, 0); - } - putstr("my pid is "); - v = syscall(SYS_getpid, 0, 0, 0, 0, 0, 0); - putint_hex(v); - putc('\n'); - - putint_hex(v); - putstr(" is exiting"); - putc('\n'); - syscall(SYS_exit, 0, 0, 0, 0, 0, 0); -} diff --git a/user/src/arch/aarch64/user.ld b/user/src/arch/aarch64/user.ld deleted file mode 100644 index b989922..0000000 --- a/user/src/arch/aarch64/user.ld +++ /dev/null @@ -1,46 +0,0 @@ -/* Simple linker script for ucore user-level programs. - See the GNU ld 'info' manual ("info ld") to learn the syntax. */ - -OUTPUT_ARCH(aarch64) -ENTRY(_start) - -SECTIONS { - /* Load programs at this address: "." means the current address */ - . = 0xffff000000000000; - - .text : { - *(.text .stub .text.* .gnu.linkonce.t.*) - } - - PROVIDE(etext = .); /* Define the 'etext' symbol to this value */ - - .rodata : { - *(.rodata .rodata.* .gnu.linkonce.r.*) - } - - /* Adjust the address for the data segment to the next page */ - . = ALIGN(0x1000); - - /* The data segment */ - .data : { - *(.data) - *(.data.*) - } - - .sdata : { - *(.sdata) - *(.sdata.*) - } - - PROVIDE(edata = .); - - .bss : { - *(.bss) - } - - PROVIDE(end = .); - - /DISCARD/ : { - *(.eh_frame .note.GNU-stack .comment) - } -} diff --git a/user/src/arch/riscv32/user.ld b/user/src/arch/riscv32/user.ld deleted file mode 100644 index 80ac4e5..0000000 --- a/user/src/arch/riscv32/user.ld +++ /dev/null @@ -1,46 +0,0 @@ -/* Simple linker script for ucore user-level programs. - See the GNU ld 'info' manual ("info ld") to learn the syntax. */ - -OUTPUT_ARCH(riscv) -ENTRY(_start) - -SECTIONS { - /* Load programs at this address: "." means the current address */ - . = 0x800020; - - .text : { - *(.text .stub .text.* .gnu.linkonce.t.*) - } - - PROVIDE(etext = .); /* Define the 'etext' symbol to this value */ - - .rodata : { - *(.rodata .rodata.* .gnu.linkonce.r.*) - } - - /* Adjust the address for the data segment to the next page */ - . = ALIGN(0x1000); - - /* The data segment */ - .data : { - *(.data) - *(.data.*) - } - - .sdata : { - *(.sdata) - *(.sdata.*) - } - - PROVIDE(edata = .); - - .bss : { - *(.bss) - } - - PROVIDE(end = .); - - /DISCARD/ : { - *(.eh_frame .note.GNU-stack .comment) - } -} diff --git a/user/src/arch/x86_64/user.ld b/user/src/arch/x86_64/user.ld deleted file mode 100644 index b135c9f..0000000 --- a/user/src/arch/x86_64/user.ld +++ /dev/null @@ -1,46 +0,0 @@ -/* Simple linker script for ucore user-level programs. - See the GNU ld 'info' manual ("info ld") to learn the syntax. */ - -OUTPUT_ARCH(x86_64) -ENTRY(_start) - -SECTIONS { - /* Load programs at this address: "." means the current address */ - . = 0x800020; - - .text : { - *(.text .stub .text.* .gnu.linkonce.t.*) - } - - PROVIDE(etext = .); /* Define the 'etext' symbol to this value */ - - .rodata : { - *(.rodata .rodata.* .gnu.linkonce.r.*) - } - - /* Adjust the address for the data segment to the next page */ - . = ALIGN(0x1000); - - /* The data segment */ - .data : { - *(.data) - *(.data.*) - } - - .sdata : { - *(.sdata) - *(.sdata.*) - } - - PROVIDE(edata = .); - - .bss : { - *(.bss) - } - - PROVIDE(end = .); - - /DISCARD/ : { - *(.eh_frame .note.GNU-stack .comment) - } -} diff --git a/user/targets/aarch64-rcore.json b/user/targets/aarch64-rcore.json index 7d9e167..a4adac2 100644 --- a/user/targets/aarch64-rcore.json +++ b/user/targets/aarch64-rcore.json @@ -15,7 +15,7 @@ "linker-is-gnu": true, "pre-link-args": { "ld.lld": [ - "-Tsrc/arch/aarch64/user.ld" + "--image-base=0xffff000000000000" ] }, "llvm-target": "aarch64-unknown-none", diff --git a/user/targets/riscv32-rcore.json b/user/targets/riscv32-rcore.json index d3456c7..aa03e0c 100644 --- a/user/targets/riscv32-rcore.json +++ b/user/targets/riscv32-rcore.json @@ -11,11 +11,6 @@ "max-atomic-width": "32", "linker": "rust-lld", "linker-flavor": "ld.lld", - "pre-link-args": { - "ld.lld": [ - "-Tsrc/arch/riscv32/user.ld" - ] - }, "executables": true, "panic-strategy": "abort", "relocation-model": "static", diff --git a/user/targets/riscv64-rcore.json b/user/targets/riscv64-rcore.json index 4742c08..fe95ada 100644 --- a/user/targets/riscv64-rcore.json +++ b/user/targets/riscv64-rcore.json @@ -7,15 +7,10 @@ "os": "none", "arch": "riscv64", "cpu": "generic-rv64", - "features": "", - "max-atomic-width": "32", + "features": "+m,+a,+c", + "max-atomic-width": "64", "linker": "rust-lld", "linker-flavor": "ld.lld", - "pre-link-args": { - "ld.lld": [ - "-Tsrc/arch/riscv32/boot/linker64.ld" - ] - }, "executables": true, "panic-strategy": "abort", "relocation-model": "static", diff --git a/user/targets/x86_64-rcore.json b/user/targets/x86_64-rcore.json index a8ace2c..6510efa 100644 --- a/user/targets/x86_64-rcore.json +++ b/user/targets/x86_64-rcore.json @@ -9,11 +9,6 @@ "executables": true, "linker": "rust-lld", "linker-flavor": "ld.lld", - "pre-link-args": { - "ld.lld": [ - "-Tsrc/arch/x86_64/user.ld" - ] - }, "panic-strategy": "abort", "disable-redzone": true, "features": "-mmx,-sse,+soft-float"