Skip to content

Latest commit

 

History

History
373 lines (217 loc) · 7.77 KB

File metadata and controls

373 lines (217 loc) · 7.77 KB

Hart

#include <hart.hpp>

class Hart

Defined in include/hart.hpp:39

RISC-V CPU Core.

List of all members

Name Kind Owner
Hart function Declared here
~Hart function Declared here
get_effective_mode function Declared here
get_mmio function Declared here
get_mmap function Declared here
get_reservation function Declared here
get_mmu function Declared here
clear_decode_cache function Declared here
get_memsize function Declared here
amo_check_reservation function Declared here
csr_read function Declared here
csr_write function Declared here
trap function Declared here
PrivilegeMode enum Declared here
run_blocks function Declared here

Public Methods

Return Name Description
Hart Hart constructor.
~Hart inline Hart destructor.
PrivilegeMode get_effective_mode const inline Returns CPU Effective mode for a specific memory access.
MMIO * get_mmio inline Returns MMIO pointer.
MemoryMap * get_mmap inline Returns MemoryMap pointer.
Reservation & get_reservation inline Returns CPU Atomic Reservation.
MMU & get_mmu inline Returns CPU Memory Management Unit.
void clear_decode_cache inline Clears Instruction Decoder Cache.
constuint64_t get_memsize const inline Returns RAM size.
void amo_check_reservation inline Clears reservation if defined address is within CPU reservation address.
uint64_t csr_read Returns value stored in CSR.
void csr_write Stores value to CSR.
void trap CPU Trap function.

Hart

Hart(uint8_t id, uint64_t memsize)

Defined in include/hart.hpp:71

Hart constructor.

Creates RISC-V core

Note

It must be equal with memory size defined in machine config.

Parameters

Parameter Type Description
id uint8_t Internal Hart ID (starts from 0)
memsize uint64_t Memory size

~Hart

inline

inline ~Hart()

Defined in include/hart.hpp:78

Hart destructor.

Destroys RISC-V core


get_effective_mode

const inline

inline PrivilegeMode get_effective_mode(AccessType access_type) const

Defined in include/hart.hpp:138

Returns CPU Effective mode for a specific memory access.

Effective mode corresponds to MPRV bit in mstatus: 1 - MPP (only for LOAD/STORE), 0 - current mode

Returns

Effective mode

See also: PrivilegeMode


get_mmio

inline

inline MMIO * get_mmio()

Defined in include/hart.hpp:151

Returns MMIO pointer.

See also: MMIO

Returns

MMIO Pointer


get_mmap

inline

inline MemoryMap * get_mmap()

Defined in include/hart.hpp:157

Returns MemoryMap pointer.

See also: MemoryMap

Returns

MemoryMap pointer


get_reservation

inline

inline Reservation & get_reservation()

Defined in include/hart.hpp:163

Returns CPU Atomic Reservation.

See also: Reservation

Returns

Reservation reference object


get_mmu

inline

inline MMU & get_mmu()

Defined in include/hart.hpp:169

Returns CPU Memory Management Unit.

See also: MMU

Returns

MMU reference


clear_decode_cache

inline

inline void clear_decode_cache()

Defined in include/hart.hpp:173

Clears Instruction Decoder Cache.


get_memsize

const inline

inline constuint64_t get_memsize() const

Defined in include/hart.hpp:187

Returns RAM size.

Returns

Memory size in bytes


amo_check_reservation

inline

inline void amo_check_reservation(uint64_t pa)

Defined in include/hart.hpp:192

Clears reservation if defined address is within CPU reservation address.


csr_read

uint64_t csr_read(uint16_t csr)

Defined in include/hart.hpp:204

Returns value stored in CSR.

Returns

CSR value

Parameters

Parameter Type Description
csr uint16_t CSR address

csr_write

void csr_write(uint16_t csr, uint64_t val)

Defined in include/hart.hpp:210

Stores value to CSR.

Parameters

Parameter Type Description
csr uint16_t CSR address
val uint64_t Value

trap

void trap(uint64_t cause, uint64_t tval, bool interrupt)

Defined in include/hart.hpp:219

CPU Trap function.

Raises trap in CPU core.

Parameters

Parameter Type Description
cause uint64_t Trap cause
tval uint64_t Trap value (can be zero)
interrupt bool Is trap will be interrupt(true) of exception(false)?

Public Types

Name Description
PrivilegeMode CPU PrivilegeMode.

PrivilegeMode

enum PrivilegeMode

Defined in include/hart.hpp:46

CPU PrivilegeMode.

Current CPU privilege mode.

Value Description
User
Supervisor
Hypervisor
Machine

Private Methods

Return Name Description
uint64_t run_blocks Block-chaining fast path (lightweight JIT).

run_blocks

uint64_t run_blocks(BlockCache & bc, uint64_t max_insts)

Defined in include/hart.hpp:247

Block-chaining fast path (lightweight JIT).

Runs precompiled straight-line blocks of the guest code, bypassing the per-instruction decode probe and MMU translate. Returns the number of instructions executed.

See also: BlockCache