mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-23 21:39:10 -04:00
satp_ is not set, then we skip VAT
This commit is contained in:
parent
2e61dad11f
commit
6d480b3da1
6 changed files with 63 additions and 32 deletions
|
@ -121,21 +121,25 @@ public:
|
|||
}
|
||||
bool need_trans(uint64_t dev_pAddr)
|
||||
{
|
||||
// Check if the this is the BARE mode
|
||||
bool isBAREMode = (get_mode() == BARE);
|
||||
|
||||
// Check if the satp is set and BARE mode
|
||||
if (processor_.is_satp_unset() || get_mode() == BARE)
|
||||
return 0;
|
||||
|
||||
// Check if the address is reserved for system usage
|
||||
// bool isReserved = (PAGE_TABLE_BASE_ADDR <= dev_pAddr && dev_pAddr < PAGE_TABLE_BASE_ADDR + PT_SIZE_LIMIT);
|
||||
bool isReserved = (PAGE_TABLE_BASE_ADDR <= dev_pAddr);
|
||||
if (PAGE_TABLE_BASE_ADDR <= dev_pAddr)
|
||||
return 0;
|
||||
|
||||
// Check if the address is reserved for IO usage
|
||||
bool isIO = (dev_pAddr < USER_BASE_ADDR);
|
||||
if (dev_pAddr < USER_BASE_ADDR)
|
||||
return 0;
|
||||
// Check if the address falls within the startup address range
|
||||
bool isStartAddress = (STARTUP_ADDR <= dev_pAddr) && (dev_pAddr <= (STARTUP_ADDR + 0x40000));
|
||||
if ((STARTUP_ADDR <= dev_pAddr) && (dev_pAddr <= (STARTUP_ADDR + 0x40000)))
|
||||
return 0;
|
||||
|
||||
// Print the boolean results for debugging purposes
|
||||
// printf("%p, %u, %u\n", (void *)dev_pAddr, isReserved, isStartAddress);
|
||||
|
||||
// Return true if the address needs translation (i.e., it's not reserved and not a start address)
|
||||
return (!isBAREMode && !isReserved && !isIO && !isStartAddress);
|
||||
// Now all conditions are not met. Return true because the address needs translation
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint64_t phy_to_virt_map(uint64_t size, uint64_t *dev_pAddr, uint32_t flags)
|
||||
|
|
|
@ -596,16 +596,26 @@ void RAM::loadHexImage(const char* filename) {
|
|||
|
||||
uint64_t MemoryUnit::get_base_ppn()
|
||||
{
|
||||
assert(satp_!= NULL);
|
||||
return satp_->get_base_ppn();
|
||||
}
|
||||
|
||||
uint64_t MemoryUnit::get_satp()
|
||||
{
|
||||
return satp_->get_satp();
|
||||
if (is_satp_unset())
|
||||
return 0;
|
||||
else
|
||||
return satp_->get_satp();
|
||||
}
|
||||
|
||||
uint8_t MemoryUnit::is_satp_unset()
|
||||
{
|
||||
return (satp_==NULL);
|
||||
}
|
||||
|
||||
uint8_t MemoryUnit::get_mode()
|
||||
{
|
||||
assert(satp_!= NULL);
|
||||
return satp_->get_mode();
|
||||
}
|
||||
void MemoryUnit::set_satp(uint64_t satp)
|
||||
|
@ -616,22 +626,26 @@ void MemoryUnit::set_satp(uint64_t satp)
|
|||
|
||||
bool MemoryUnit::need_trans(uint64_t dev_pAddr)
|
||||
{
|
||||
// Check if the this is the BARE mode
|
||||
bool isBAREMode = (get_mode() == BARE);
|
||||
// Check if the address is reserved for system usage
|
||||
// bool isReserved = (PAGE_TABLE_BASE_ADDR <= dev_pAddr && dev_pAddr < PAGE_TABLE_BASE_ADDR + PT_SIZE_LIMIT);
|
||||
bool isReserved = (PAGE_TABLE_BASE_ADDR <= dev_pAddr);
|
||||
// Check if the address is reserved for IO usage
|
||||
bool isIO= (dev_pAddr < USER_BASE_ADDR);
|
||||
// Check if the address falls within the startup address range
|
||||
bool isStartAddress = (STARTUP_ADDR <= dev_pAddr) && (dev_pAddr <= (STARTUP_ADDR + 0x40000));
|
||||
|
||||
// Print the boolean results for debugging purposes
|
||||
// printf("%p, %u, %u\n", (void *)dev_pAddr, isReserved, isStartAddress);
|
||||
// Check if the satp is set and BARE mode
|
||||
if ( is_satp_unset() || (get_mode() == BARE))
|
||||
return 0;
|
||||
|
||||
// Return true if the address needs translation (i.e., it's not reserved and not a start address)
|
||||
return (!isBAREMode && !isReserved && !isIO && !isStartAddress);
|
||||
// Check if the address is reserved for system usage
|
||||
// bool isReserved = (PAGE_TABLE_BASE_ADDR <= dev_pAddr && dev_pAddr < PAGE_TABLE_BASE_ADDR + PT_SIZE_LIMIT);
|
||||
if (PAGE_TABLE_BASE_ADDR <= dev_pAddr)
|
||||
return 0;
|
||||
|
||||
// Check if the address is reserved for IO usage
|
||||
if (dev_pAddr < USER_BASE_ADDR)
|
||||
return 0;
|
||||
// Check if the address falls within the startup address range
|
||||
if ((STARTUP_ADDR <= dev_pAddr) && (dev_pAddr <= (STARTUP_ADDR + 0x40000)))
|
||||
return 0;
|
||||
|
||||
// Now all conditions are not met. Return true because the address needs translation
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint64_t MemoryUnit::vAddr_to_pAddr(uint64_t vAddr, ACCESS_TYPE type)
|
||||
{
|
||||
uint64_t pfn;
|
||||
|
|
|
@ -186,8 +186,12 @@ public:
|
|||
};
|
||||
|
||||
#ifdef VM_ENABLE
|
||||
MemoryUnit(uint64_t pageSize = MEM_PAGE_SIZE);
|
||||
~MemoryUnit(){delete this->satp_;};
|
||||
MemoryUnit(uint64_t pageSize = MEM_PAGE_SIZE) :satp_(NULL)
|
||||
{};
|
||||
~MemoryUnit(){
|
||||
if ( this->satp_ != NULL)
|
||||
delete this->satp_;
|
||||
};
|
||||
#else
|
||||
MemoryUnit(uint64_t pageSize = 0);
|
||||
#endif
|
||||
|
@ -208,6 +212,7 @@ public:
|
|||
|
||||
#ifdef VM_ENABLE
|
||||
void tlbAdd(uint64_t virt, uint64_t phys, uint32_t flags, uint64_t size_bits);
|
||||
uint8_t is_satp_unset();
|
||||
uint64_t get_satp();
|
||||
uint8_t get_mode();
|
||||
uint64_t get_base_ppn();
|
||||
|
|
|
@ -125,9 +125,6 @@ private:
|
|||
uint32_t ipdom_size_;
|
||||
Word csr_mscratch_;
|
||||
wspawn_t wspawn_;
|
||||
#ifdef VM_ENABLE
|
||||
Word ptbr_;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -145,12 +145,17 @@ ProcessorImpl::PerfStats ProcessorImpl::perf_stats() const {
|
|||
|
||||
Processor::Processor(const Arch& arch)
|
||||
: impl_(new ProcessorImpl(arch))
|
||||
{}
|
||||
{
|
||||
#ifdef VM_ENABLE
|
||||
satp_ = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Processor::~Processor() {
|
||||
delete impl_;
|
||||
#ifdef VM_ENABLE
|
||||
delete satp_;
|
||||
if (satp_ != NULL)
|
||||
delete satp_;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -176,10 +181,15 @@ int16_t Processor::set_satp_by_addr(uint64_t base_addr) {
|
|||
impl_->set_satp(satp);
|
||||
return 0;
|
||||
}
|
||||
bool Processor::is_satp_unset() {
|
||||
return (satp_== NULL);
|
||||
}
|
||||
uint8_t Processor::get_satp_mode() {
|
||||
assert (satp_!=NULL);
|
||||
return satp_->get_mode();
|
||||
}
|
||||
uint64_t Processor::get_base_ppn() {
|
||||
assert (satp_!=NULL);
|
||||
return satp_->get_base_ppn();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
void dcr_write(uint32_t addr, uint32_t value);
|
||||
#ifdef VM_ENABLE
|
||||
bool is_satp_unset();
|
||||
uint8_t get_satp_mode();
|
||||
uint64_t get_base_ppn();
|
||||
int16_t set_satp_by_addr(uint64_t addr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue