├── .cargo
└── config.toml
├── .github
├── scripts
│ ├── add-doc-index.sh
│ └── make-qemu.sh
└── workflows
│ ├── build.yml
│ ├── docs.yml
│ └── test.yml
├── .gitignore
├── .gitmodules
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── Makefile
├── README-arch.md
├── README.md
├── config
└── machine-features.toml
├── docs
├── README-C910.md
├── README-D1.md
├── README-fu740.md
├── README-visionfive.md
├── README_EN.md
├── for-developers.md
├── img
│ ├── c906-amo-1.jpg
│ ├── c906-amo-2.jpg
│ ├── c906-clear-bss.jpeg
│ ├── c910-jtag.jpg
│ ├── c910-light.jpeg
│ ├── c910-linux-pg.png
│ ├── c910-maee.jpeg
│ ├── c910-mxstatus.png
│ ├── c910-pte-flags.png
│ ├── c910-run-uart.png
│ └── c910-zcore-run.png
├── porting-rv64.md
├── structure.svg
└── visionfive.jpg
├── drivers
├── Cargo.toml
└── src
│ ├── builder
│ ├── devicetree.rs
│ └── mod.rs
│ ├── bus
│ ├── mod.rs
│ └── pci.rs
│ ├── display
│ ├── mod.rs
│ ├── resource
│ │ └── cursor.bin
│ └── uefi.rs
│ ├── input
│ ├── input_event_codes.rs
│ ├── mod.rs
│ └── mouse.rs
│ ├── io
│ ├── mmio.rs
│ ├── mod.rs
│ └── pmio.rs
│ ├── irq
│ ├── gic_400.rs
│ ├── mod.rs
│ ├── riscv_intc.rs
│ ├── riscv_plic.rs
│ └── x86_apic
│ │ ├── consts.rs
│ │ ├── ioapic.rs
│ │ ├── lapic.rs
│ │ └── mod.rs
│ ├── lib.rs
│ ├── mock
│ ├── display.rs
│ ├── graphic
│ │ ├── mod.rs
│ │ └── sdl.rs
│ ├── input.rs
│ ├── mod.rs
│ └── uart.rs
│ ├── net
│ ├── e1000.rs
│ ├── loopback.rs
│ ├── mod.rs
│ ├── realtek
│ │ ├── mii.rs
│ │ ├── mod.rs
│ │ ├── rtl8211f.rs
│ │ └── utils.rs
│ └── rtlx.rs
│ ├── nvme
│ ├── interface.rs
│ ├── mod.rs
│ └── nvme_queue.rs
│ ├── prelude.rs
│ ├── scheme
│ ├── block.rs
│ ├── display.rs
│ ├── event.rs
│ ├── input.rs
│ ├── irq.rs
│ ├── mod.rs
│ ├── net.rs
│ └── uart.rs
│ ├── uart
│ ├── buffered.rs
│ ├── mod.rs
│ ├── uart_16550.rs
│ ├── uart_allwinner.rs
│ ├── uart_pl011.rs
│ └── uart_u740.rs
│ ├── utils
│ ├── devicetree.rs
│ ├── event_listener.rs
│ ├── graphic_console.rs
│ ├── id_allocator.rs
│ ├── irq_manager.rs
│ └── mod.rs
│ └── virtio
│ ├── blk.rs
│ ├── console.rs
│ ├── gpu.rs
│ ├── input.rs
│ └── mod.rs
├── kernel-hal
├── Cargo.toml
└── src
│ ├── bare
│ ├── arch
│ │ ├── aarch64
│ │ │ ├── config.rs
│ │ │ ├── cpu.rs
│ │ │ ├── drivers.rs
│ │ │ ├── interrupt.rs
│ │ │ ├── mem.rs
│ │ │ ├── mod.rs
│ │ │ ├── timer.rs
│ │ │ ├── trap.rs
│ │ │ └── vm.rs
│ │ ├── riscv
│ │ │ ├── config.rs
│ │ │ ├── cpu.rs
│ │ │ ├── drivers.rs
│ │ │ ├── interrupt.rs
│ │ │ ├── mem.rs
│ │ │ ├── mod.rs
│ │ │ ├── sbi.rs
│ │ │ ├── timer.rs
│ │ │ ├── trap.rs
│ │ │ └── vm.rs
│ │ └── x86_64
│ │ │ ├── config.rs
│ │ │ ├── cpu.rs
│ │ │ ├── drivers.rs
│ │ │ ├── interrupt.rs
│ │ │ ├── mem.rs
│ │ │ ├── mod.rs
│ │ │ ├── special.rs
│ │ │ ├── timer.rs
│ │ │ ├── trap.rs
│ │ │ └── vm.rs
│ ├── boot.rs
│ ├── mem.rs
│ ├── mod.rs
│ ├── net.rs
│ ├── thread.rs
│ └── timer.rs
│ ├── common
│ ├── addr.rs
│ ├── console.rs
│ ├── context.rs
│ ├── defs.rs
│ ├── future.rs
│ ├── ipi.rs
│ ├── mem.rs
│ ├── mod.rs
│ ├── thread.rs
│ ├── user.rs
│ ├── vdso.rs
│ └── vm.rs
│ ├── config.rs
│ ├── drivers.rs
│ ├── hal_fn.rs
│ ├── kernel_handler.rs
│ ├── lib.rs
│ ├── libos
│ ├── boot.rs
│ ├── config.rs
│ ├── cpu.rs
│ ├── drivers.rs
│ ├── dummy.rs
│ ├── interrupt.rs
│ ├── macos.rs
│ ├── mem.rs
│ ├── mock_mem.rs
│ ├── mod.rs
│ ├── net.rs
│ ├── special.rs
│ ├── thread.rs
│ ├── timer.rs
│ ├── vdso.rs
│ └── vm.rs
│ ├── macros.rs
│ └── utils
│ ├── init_once.rs
│ ├── lazy_init.rs
│ ├── mod.rs
│ ├── mpsc_queue.rs
│ └── page_table.rs
├── linux-object
├── Cargo.toml
└── src
│ ├── error.rs
│ ├── fs
│ ├── devfs
│ │ ├── fbdev.rs
│ │ ├── input
│ │ │ ├── event.rs
│ │ │ ├── mice.rs
│ │ │ └── mod.rs
│ │ ├── mod.rs
│ │ ├── random.rs
│ │ └── uartdev.rs
│ ├── file.rs
│ ├── ioctl.rs
│ ├── mock.rs
│ ├── mod.rs
│ ├── pipe.rs
│ ├── pseudo.rs
│ ├── rcore_fs_wrapper.rs
│ └── stdio.rs
│ ├── ipc
│ ├── mod.rs
│ ├── semary.rs
│ └── shared_mem.rs
│ ├── lib.rs
│ ├── loader
│ ├── abi.rs
│ └── mod.rs
│ ├── net
│ ├── mod.rs
│ ├── netlink.rs
│ ├── raw.rs
│ ├── socket_address.rs
│ ├── tcp.rs
│ └── udp.rs
│ ├── process.rs
│ ├── signal
│ ├── action.rs
│ └── mod.rs
│ ├── sync
│ ├── event_bus.rs
│ ├── mod.rs
│ └── semaphore.rs
│ ├── thread.rs
│ └── time.rs
├── linux-syscall
├── Cargo.toml
├── build.rs
├── src
│ ├── aarch64_syscall.h.in
│ ├── file
│ │ ├── dir.rs
│ │ ├── fd.rs
│ │ ├── file.rs
│ │ ├── mod.rs
│ │ ├── poll.rs
│ │ └── stat.rs
│ ├── ipc.rs
│ ├── lib.rs
│ ├── misc.rs
│ ├── net.rs
│ ├── riscv64_syscall.h.in
│ ├── signal.rs
│ ├── syscall.h.in
│ ├── task.rs
│ ├── time.rs
│ └── vm.rs
└── test
│ ├── testpipe1.c
│ ├── testpipe2.c
│ ├── testpoll.c
│ ├── testrandom.c
│ ├── testselect.c
│ ├── testsem1.c
│ ├── testsem2.c
│ ├── testshm1.c
│ ├── testshm2.c
│ └── testtime.c
├── loader
├── Cargo.toml
├── examples
│ ├── linux-libos.rs
│ └── zircon-libos.rs
├── src
│ ├── lib.rs
│ ├── linux.rs
│ └── zircon.rs
└── tests
│ ├── linux.rs
│ └── zircon.rs
├── prebuilt
└── firmware
│ ├── aarch64
│ ├── Boot.json
│ ├── QEMU_EFI.fd
│ └── aarch64_uefi.efi
│ └── riscv
│ ├── c910_fw_dynamic.bin
│ ├── d1_fw_payload.elf
│ ├── fu740_fdt.its
│ ├── hifive-unmatched-a00.dtb
│ ├── starfive.dtb
│ └── starfive_fdt.its
├── rust-toolchain.toml
├── scripts
├── gen-prebuilt.sh
├── script.sh
├── zcore.patch
└── zircon-libos.patch
├── tools
└── docker
│ ├── README.md
│ ├── build_docker_image.sh
│ ├── start_container.sh
│ └── zcore-ubuntu.dockerfile
├── xtask
├── CHANGELOG.md
├── Cargo.toml
├── build.rs
└── src
│ ├── arch.rs
│ ├── build.rs
│ ├── commands.rs
│ ├── dump.rs
│ ├── errors.rs
│ ├── linux
│ ├── image.rs
│ ├── mod.rs
│ ├── opencv.rs
│ └── test.rs
│ └── main.rs
├── z-config
├── Cargo.toml
└── src
│ └── lib.rs
├── zCore
├── .gdbinit_riscv64
├── .gdbinit_x86_64
├── Cargo.toml
├── Makefile
├── aarch64.json
├── build.rs
├── rboot.conf
├── rboot.conf.default
├── riscv64.json
├── src
│ ├── fs.rs
│ ├── handler.rs
│ ├── lang.rs
│ ├── logging.rs
│ ├── main.rs
│ ├── memory.rs
│ ├── memory_x86_64.rs
│ ├── platform
│ │ ├── aarch64
│ │ │ ├── consts.rs
│ │ │ ├── entry.rs
│ │ │ ├── linker.ld
│ │ │ ├── mod.rs
│ │ │ └── space.s
│ │ ├── libos
│ │ │ ├── consts.rs
│ │ │ ├── entry.rs
│ │ │ └── mod.rs
│ │ ├── mod.rs
│ │ ├── riscv
│ │ │ ├── boot.asm
│ │ │ ├── boot_page_table.rs
│ │ │ ├── consts.rs
│ │ │ ├── entry.rs
│ │ │ ├── entry64.rs
│ │ │ ├── linker.ld
│ │ │ └── mod.rs
│ │ └── x86
│ │ │ ├── consts.rs
│ │ │ ├── entry.rs
│ │ │ ├── linker.ld
│ │ │ └── mod.rs
│ └── utils.rs
└── x86_64.json
├── zircon-object
├── Cargo.toml
└── src
│ ├── debuglog.rs
│ ├── dev
│ ├── bti.rs
│ ├── interrupt
│ │ ├── event_interrupt.rs
│ │ ├── mod.rs
│ │ ├── pci_interrupt.rs
│ │ └── virtual_interrupt.rs
│ ├── iommu.rs
│ ├── mod.rs
│ ├── pci
│ │ ├── bus.rs
│ │ ├── caps.rs
│ │ ├── config.rs
│ │ ├── mod.rs
│ │ ├── nodes.rs
│ │ ├── pci_init_args.rs
│ │ └── pmio.rs
│ ├── pmt.rs
│ └── resource.rs
│ ├── error.rs
│ ├── hypervisor
│ ├── guest.rs
│ ├── mod.rs
│ └── vcpu.rs
│ ├── ipc
│ ├── channel.rs
│ ├── fifo.rs
│ ├── mod.rs
│ └── socket.rs
│ ├── lib.rs
│ ├── object
│ ├── handle.rs
│ ├── mod.rs
│ ├── rights.rs
│ └── signal.rs
│ ├── signal
│ ├── event.rs
│ ├── eventpair.rs
│ ├── futex.rs
│ ├── mod.rs
│ ├── port.rs
│ ├── port_packet.rs
│ └── timer.rs
│ ├── task
│ ├── exception.rs
│ ├── job.rs
│ ├── job_policy.rs
│ ├── mod.rs
│ ├── process.rs
│ ├── suspend_token.rs
│ ├── thread.rs
│ └── thread
│ │ └── thread_state.rs
│ ├── util
│ ├── block_range.rs
│ ├── elf_loader.rs
│ ├── kcounter.rs
│ └── mod.rs
│ └── vm
│ ├── mod.rs
│ ├── stream.rs
│ ├── vmar.rs
│ └── vmo
│ ├── mod.rs
│ ├── paged.rs
│ ├── physical.rs
│ └── slice.rs
├── zircon-syscall
├── Cargo.toml
├── build.rs
└── src
│ ├── channel.rs
│ ├── consts.rs
│ ├── cprng.rs
│ ├── ddk.rs
│ ├── debug.rs
│ ├── debuglog.rs
│ ├── exception.rs
│ ├── fifo.rs
│ ├── futex.rs
│ ├── handle.rs
│ ├── hypervisor.rs
│ ├── lib.rs
│ ├── object.rs
│ ├── pci.rs
│ ├── port.rs
│ ├── resource.rs
│ ├── signal.rs
│ ├── socket.rs
│ ├── stream.rs
│ ├── system.rs
│ ├── task.rs
│ ├── time.rs
│ ├── vmar.rs
│ ├── vmo.rs
│ └── zx-syscall-numbers.h
└── zircon-user
├── .cargo
└── config
├── Cargo.lock
├── Cargo.toml
├── Makefile
├── rust-toolchain.toml
└── src
└── bin
└── hello.rs
/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [alias]
2 | xtask = "run --package xtask --release --"
3 | git-proxy = "xtask git-proxy"
4 | zircon-init = "xtask zircon-init"
5 | update-all = "xtask update-all"
6 |
7 | check-style = "xtask check-style"
8 |
9 | rootfs = "xtask rootfs"
10 | musl-libs = "xtask musl-libs"
11 | opencv = "xtask opencv"
12 | ffmpeg = "xtask ffmpeg"
13 | libc-test = "xtask libc-test"
14 | other-test = "xtask other-test"
15 | image = "xtask image"
16 |
17 | linux-libos = "xtask linux-libos"
18 |
19 | asm = "xtask asm"
20 | bin = "xtask bin"
21 | qemu = "xtask qemu"
22 | gdb = "xtask gdb"
23 |
--------------------------------------------------------------------------------
/.github/scripts/add-doc-index.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cat > target/doc/index.html << EOF
4 |
5 |
6 |
7 | Redirection
8 |
9 |
10 | Redirecting to kernel_hal/index.html...
11 |
12 |
13 | EOF
--------------------------------------------------------------------------------
/.github/scripts/make-qemu.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | wget https://download.qemu.org/qemu-$1.tar.xz
4 | tar -xJf qemu-$1.tar.xz
5 | cd qemu-$1
6 | ./configure --target-list=x86_64-softmmu,riscv64-softmmu,aarch64-softmmu
7 | make -j > /dev/null 2>&1
8 |
--------------------------------------------------------------------------------
/.github/workflows/docs.yml:
--------------------------------------------------------------------------------
1 | name: Deploy docs
2 |
3 | on:
4 | push:
5 | pull_request:
6 |
7 | env:
8 | rust_toolchain: nightly-2022-08-05
9 |
10 | jobs:
11 | doc:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - uses: actions/checkout@v3
15 |
16 | - uses: actions-rs/toolchain@v1
17 | with:
18 | profile: minimal
19 | toolchain: ${{ env.rust_toolchain }}
20 |
21 | - name: Pull prebuilt images
22 | run: make zircon-init
23 |
24 | - name: Build docs
25 | run: |
26 | cargo doc --no-deps --all-features --workspace
27 | .github/scripts/add-doc-index.sh
28 |
29 | - name: Deploy to Github Pages
30 | if: ${{ github.ref == 'refs/heads/master' }}
31 | uses: JamesIves/github-pages-deploy-action@releases/v3
32 | with:
33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 | BRANCH: gh-pages
35 | FOLDER: target/doc
36 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/.*/*
2 | !.github/*
3 | !.cargo/*
4 |
5 | **/target
6 | *.img
7 |
8 | /ignored
9 | /rootfs
10 | # for aarch64 only
11 | /zCore/disk
12 |
13 | .DS_Store
14 | __pycache__
15 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "rboot"]
2 | path = rboot
3 | url = https://github.com/rcore-os/rboot.git
4 | [submodule "tests"]
5 | path = tests
6 | url = https://github.com/rcore-os/zcore-tests.git
7 | [submodule "libc-test"]
8 | path = libc-test
9 | url = https://github.com/rcore-os/libc-test
10 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 | members = [
3 | "drivers",
4 | "kernel-hal",
5 | "zircon-object",
6 | "zircon-syscall",
7 | "linux-object",
8 | "linux-syscall",
9 | "loader",
10 | "zCore",
11 | "z-config",
12 | "xtask",
13 | ]
14 | default-members = ["xtask"]
15 | exclude = ["zircon-user", "rboot"]
16 |
17 | [profile.release]
18 | lto = true
19 | debug = true
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019-2020 rCore Developers
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for top level of zCore
2 |
3 | ARCH ?= x86_64
4 | XTASK ?= 1
5 |
6 | STRIP := $(ARCH)-linux-musl-strip
7 | export PATH=$(shell printenv PATH):$(CURDIR)/ignored/target/$(ARCH)/$(ARCH)-linux-musl-cross/bin/
8 |
9 | .PHONY: help zircon-init update rootfs libc-test other-test image check doc clean
10 |
11 | # print top level help
12 | help:
13 | cargo xtask
14 |
15 | # download zircon binaries
16 | zircon-init:
17 | cargo zircon-init
18 |
19 | # update toolchain and dependencies
20 | update:
21 | cargo update-all
22 |
23 | # put rootfs for linux mode
24 | rootfs:
25 | ifeq ($(XTASK), 1)
26 | cargo rootfs --arch $(ARCH)
27 | else ifeq ($(ARCH), riscv64)
28 | @rm -rf rootfs/riscv && mkdir -p rootfs/riscv/bin
29 | @wget https://github.com/rcore-os/busybox-prebuilts/raw/master/busybox-1.30.1-riscv64/busybox -O rootfs/riscv/bin/busybox
30 | @ln -s busybox rootfs/riscv/bin/ls
31 | endif
32 |
33 | # put libc tests into rootfs
34 | libc-test:
35 | cargo libc-test --arch $(ARCH)
36 | find rootfs/$(ARCH)/libc-test -type f \
37 | -name "*so" -o -name "*exe" -exec $(STRIP) {} \;
38 |
39 | # put other tests into rootfs
40 | other-test:
41 | cargo other-test --arch $(ARCH)
42 |
43 | # build image from rootfs
44 | image:
45 | ifeq ($(XTASK), 1)
46 | cargo image --arch $(ARCH)
47 | else ifeq ($(ARCH), riscv64)
48 | @echo building riscv.img
49 | @rcore-fs-fuse zCore/riscv64.img rootfs/riscv zip
50 | @qemu-img resize -f raw zCore/riscv64.img +5M
51 | endif
52 |
53 | # check code style
54 | check:
55 | cargo check-style
56 |
57 | # build and open project document
58 | doc:
59 | cargo doc --open
60 |
61 | # clean targets
62 | clean:
63 | cargo clean
64 | rm -f *.asm
65 | rm -rf rootfs
66 | rm -rf zCore/disk
67 | find zCore -maxdepth 1 -name "*.img" -delete
68 | find zCore -maxdepth 1 -name "*.bin" -delete
69 |
70 | # delete targets, including those that are large and compile slowly
71 | cleanup: clean
72 | rm -rf ignored/target
73 |
74 | # delete everything, including origin files that are downloaded directly
75 | clean-everything: clean
76 | rm -rf ignored
77 |
78 | # rt-test:
79 | # cd rootfs/x86_64 && git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/clrkwllms/rt-tests --depth 1
80 | # cd rootfs/x86_64/rt-tests && make
81 | # echo x86 gcc build rt-test,now need manual modificy.
82 |
--------------------------------------------------------------------------------
/config/machine-features.toml:
--------------------------------------------------------------------------------
1 | [qemu.virt-riscv64]
2 | arch = "riscv64"
3 |
4 | [qemu.virt-aarch64]
5 | arch = "aarch64"
6 |
7 | [qemu.virt-x86_64]
8 | arch = "x86_64"
9 |
10 | [allwinner.nezha]
11 | arch = "riscv64"
12 | link-user-img = "zCore/riscv64.img"
13 | pci-support = false
14 | features = ["allwinner-drivers"]
15 |
16 | [cvitek.cr1825]
17 | arch = "riscv64"
18 | link-user-img = "zCore/riscv64.img"
19 | pci-support = false
20 | features = ["thead-maee"]
21 |
22 | [starfive.visionfive]
23 | arch = "riscv64"
24 | link-user-img = "zCore/riscv64.img"
25 | pci-support = false
26 |
27 | [sifive.fu740]
28 | arch = "riscv64"
29 | link-user-img = "zCore/riscv64.img"
30 | pci-support = true
31 | features = ["fu740-drivers"]
32 |
--------------------------------------------------------------------------------
/docs/README-fu740.md:
--------------------------------------------------------------------------------
1 | # zCore on riscv64 for fu740
2 |
3 | ### 编译zCore for fu740系统镜像
4 |
5 | 先在源码根目录下编译 riscv64 的文件系统。
6 |
7 | 然后进入子目录 zCore 编译内核,会生成系统镜像`zcore-fu740.itb`
8 |
9 | 系统镜像会包含fu740板子的设备树, dtb设备树可以从fu740自带的Linux中的`/boot`目录中获取;
10 | 也可以从sifive官方镜像中获取:https://github.com/sifive/freedom-u-sdk/releases/download/2022.04.00/demo-coreip-cli-unmatched-2022.04.00.rootfs.wic.xz
11 |
12 | ```sh
13 | make riscv-image
14 | cd zCore
15 | make build MODE=release LINUX=1 ARCH=riscv64 PLATFORM=fu740
16 | ```
17 |
18 | ### 基于U-Boot启动系统镜像
19 |
20 | 首先搭建一台tftp服务器, 例如,在Linux服务器中安装`tftpd-hpa`, 一般tftp服务的目录会在`/srv/tftp/`;
21 |
22 | 然后把编译出的zCore for fu740系统镜像`zcore-fu740.itb`拷贝到tftp服务目录;
23 |
24 | 开发板fu740开机,并进入U-Boot命令行:
25 |
26 | ```
27 | # 配置开发板IP地址和服务器IP地址
28 | setenv ipaddr
29 | setenv serverip
30 |
31 | # 通过tftp协议加载系统镜像
32 | tftp 0xa0000000 zcore-fu740.itb
33 |
34 | # 运行
35 | bootm 0xa0000000
36 | ```
37 |
38 | ### fu740资料汇集
39 | Unmatched fu740 板子资料整理, 请见:
40 | https://github.com/oscomp/DocUnmatchedU740/blob/main/unmatched.md
41 |
--------------------------------------------------------------------------------
/docs/img/c906-amo-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c906-amo-1.jpg
--------------------------------------------------------------------------------
/docs/img/c906-amo-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c906-amo-2.jpg
--------------------------------------------------------------------------------
/docs/img/c906-clear-bss.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c906-clear-bss.jpeg
--------------------------------------------------------------------------------
/docs/img/c910-jtag.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-jtag.jpg
--------------------------------------------------------------------------------
/docs/img/c910-light.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-light.jpeg
--------------------------------------------------------------------------------
/docs/img/c910-linux-pg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-linux-pg.png
--------------------------------------------------------------------------------
/docs/img/c910-maee.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-maee.jpeg
--------------------------------------------------------------------------------
/docs/img/c910-mxstatus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-mxstatus.png
--------------------------------------------------------------------------------
/docs/img/c910-pte-flags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-pte-flags.png
--------------------------------------------------------------------------------
/docs/img/c910-run-uart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-run-uart.png
--------------------------------------------------------------------------------
/docs/img/c910-zcore-run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/img/c910-zcore-run.png
--------------------------------------------------------------------------------
/docs/visionfive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/docs/visionfive.jpg
--------------------------------------------------------------------------------
/drivers/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zcore-drivers"
3 | version = "0.1.0"
4 | authors = ["Yuekai Jia "]
5 | edition = "2018"
6 | description = "Device drivers of zCore"
7 |
8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9 |
10 | [features]
11 | graphic = ["rcore-console"]
12 | mock = ["async-std", "sdl2"]
13 | virtio = ["virtio-drivers"]
14 | loopback = []
15 | no-pci = []
16 |
17 | # special drivers for hardwares
18 |
19 | allwinner = ["d1-pac"]
20 | fu740 = []
21 |
22 | [dependencies]
23 | log = "0.4"
24 | cfg-if = "1.0"
25 | bitflags = "1.3"
26 | lazy_static = "1.4"
27 | numeric-enum-macro = "0.2"
28 | device_tree = { git = "https://github.com/rcore-os/device_tree-rs", rev = "2f2e55f" }
29 | bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "88e871a5" }
30 | pci = { git = "https://github.com/elliott10/pci-rs", rev = "8f33774b" }
31 | virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "2aaf7d6", optional = true }
32 | rcore-console = { git = "https://github.com/rcore-os/rcore-console", default-features = false, rev = "ca5b1bc", optional = true }
33 | lock = { git = "https://github.com/DeathWish5/kernel-sync", rev = "8486b8" }
34 | isomorphic_drivers = { git = "https://github.com/rcore-os/isomorphic_drivers", rev = "f7cd97a8", features = [
35 | "log",
36 | ] }
37 | smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp", rev = "35e833e3", default-features = false, features = [
38 | "log",
39 | "alloc",
40 | "verbose",
41 | "proto-ipv4",
42 | "proto-ipv6",
43 | "proto-igmp",
44 | "medium-ip",
45 | "medium-ethernet",
46 | "socket-raw",
47 | "socket-udp",
48 | "socket-tcp",
49 | "socket-icmp",
50 | "async",
51 | ] }
52 | d1-pac = { version = "0.0.27", optional = true }
53 | volatile = "0.3"
54 |
55 | # LibOS mode
56 | [target.'cfg(not(target_os = "none"))'.dependencies]
57 | async-std = { version = "1.10", optional = true }
58 | sdl2 = { version = "0.34", optional = true }
59 |
60 | [target.'cfg(target_arch = "x86_64")'.dependencies]
61 | acpi = "4.1"
62 | x2apic = "0.4"
63 | x86_64 = "0.14"
64 |
65 | [target.'cfg(any(target_arch = "riscv32", target_arch = "riscv64"))'.dependencies]
66 | riscv = "0.9"
67 |
--------------------------------------------------------------------------------
/drivers/src/builder/mod.rs:
--------------------------------------------------------------------------------
1 | //! Various builders to probe devices and create corresponding drivers
2 | //! (e.g. device tree, ACPI table, ...)
3 |
4 | mod devicetree;
5 |
6 | pub use devicetree::DevicetreeDriverBuilder;
7 |
8 | use crate::{PhysAddr, VirtAddr};
9 |
10 | /// A trait implemented in kernel to translate device physical addresses to virtual
11 | /// addresses.
12 | pub trait IoMapper {
13 | /// Translate the device physical address to virtual address. If not mapped
14 | /// in the kernel page table, map the region specified by the given `size`.
15 | ///
16 | /// If an error accurs during translation or mapping, returns `None`.
17 | fn query_or_map(&self, paddr: PhysAddr, size: usize) -> Option;
18 | }
19 |
--------------------------------------------------------------------------------
/drivers/src/bus/mod.rs:
--------------------------------------------------------------------------------
1 | #[cfg(any(target_arch = "x86_64", target_arch = "riscv64"))]
2 | pub mod pci;
3 |
4 | pub fn phys_to_virt(paddr: PhysAddr) -> VirtAddr {
5 | unsafe { drivers_phys_to_virt(paddr) }
6 | }
7 |
8 | pub fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr {
9 | unsafe { drivers_virt_to_phys(vaddr) }
10 | }
11 |
12 | #[allow(unused)]
13 | extern "C" {
14 | fn drivers_dma_alloc(pages: usize) -> PhysAddr;
15 | fn drivers_dma_dealloc(paddr: PhysAddr, pages: usize) -> i32;
16 | fn drivers_phys_to_virt(paddr: PhysAddr) -> VirtAddr;
17 | fn drivers_virt_to_phys(vaddr: VirtAddr) -> PhysAddr;
18 | }
19 |
20 | pub const PAGE_SIZE: usize = 4096;
21 |
22 | type VirtAddr = usize;
23 | type PhysAddr = usize;
24 |
25 | use core::ptr::{read_volatile, write_volatile};
26 | #[inline(always)]
27 | pub fn write(addr: usize, content: T) {
28 | let cell = (addr) as *mut T;
29 | unsafe {
30 | write_volatile(cell, content);
31 | }
32 | }
33 | #[inline(always)]
34 | pub fn read(addr: usize) -> T {
35 | let cell = (addr) as *const T;
36 | unsafe { read_volatile(cell) }
37 | }
38 |
--------------------------------------------------------------------------------
/drivers/src/display/mod.rs:
--------------------------------------------------------------------------------
1 | //! Only UEFI Display currently.
2 |
3 | mod uefi;
4 |
5 | pub use uefi::UefiDisplay;
6 |
--------------------------------------------------------------------------------
/drivers/src/display/resource/cursor.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcore-os/zCore/43ff1c9d09f55010741c7f7d2c50284a9d4dca6b/drivers/src/display/resource/cursor.bin
--------------------------------------------------------------------------------
/drivers/src/display/uefi.rs:
--------------------------------------------------------------------------------
1 | //! UEFI Graphics Output Protocol
2 |
3 | use crate::prelude::{DisplayInfo, FrameBuffer};
4 | use crate::scheme::{DisplayScheme, Scheme};
5 |
6 | pub struct UefiDisplay {
7 | info: DisplayInfo,
8 | }
9 |
10 | impl UefiDisplay {
11 | pub fn new(info: DisplayInfo) -> Self {
12 | Self { info }
13 | }
14 | }
15 |
16 | impl Scheme for UefiDisplay {
17 | fn name(&self) -> &str {
18 | "mock-display"
19 | }
20 | }
21 |
22 | impl DisplayScheme for UefiDisplay {
23 | #[inline]
24 | fn info(&self) -> DisplayInfo {
25 | self.info
26 | }
27 |
28 | #[inline]
29 | fn fb(&self) -> FrameBuffer {
30 | unsafe {
31 | FrameBuffer::from_raw_parts_mut(self.info.fb_base_vaddr as *mut u8, self.info.fb_size)
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/drivers/src/input/mod.rs:
--------------------------------------------------------------------------------
1 | //! Only Mouse currently.
2 |
3 | mod mouse;
4 |
5 | pub mod input_event_codes;
6 |
7 | pub use mouse::{Mouse, MouseFlags, MouseState};
8 |
--------------------------------------------------------------------------------
/drivers/src/io/mmio.rs:
--------------------------------------------------------------------------------
1 | use super::Io;
2 | use core::ops::{BitAnd, BitOr, Not};
3 |
4 | // 主存映射 I/O。
5 | /// Memory-mapped I/O.
6 | #[repr(transparent)]
7 | pub struct Mmio(T);
8 |
9 | impl Mmio {
10 | /// # Safety
11 | ///
12 | /// This function is unsafe because `base_addr` may be an arbitrary address.
13 | pub unsafe fn from_base_as<'a, R>(base_addr: usize) -> &'a mut R {
14 | assert_eq!(base_addr % core::mem::size_of::(), 0);
15 | &mut *(base_addr as *mut R)
16 | }
17 |
18 | /// # Safety
19 | ///
20 | /// This function is unsafe because `base_addr` may be an arbitrary address.
21 | pub unsafe fn from_base<'a>(base_addr: usize) -> &'a mut Self {
22 | Self::from_base_as(base_addr)
23 | }
24 |
25 | pub fn add<'a>(&self, offset: usize) -> &'a mut Self {
26 | unsafe { Self::from_base((&self.0 as *const T).add(offset) as _) }
27 | }
28 | }
29 |
30 | impl Io for Mmio
31 | where
32 | T: Copy + BitAnd