Skip to content

Commit

Permalink
#10 allocate node for cinit
Browse files Browse the repository at this point in the history
  • Loading branch information
hakase56557 committed Sep 8, 2023
1 parent ac49345 commit 637aa11
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/arch/riscvcapstone/o3/cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,17 +558,20 @@ CPU::startup()
rename.startupStage();
commit.startupStage();

Cap *cap = new Cap;
cap->setPerm(CapPerm::RWX);
cap->setType(CapType::LIN);
cap->setBound(secure_base, secure_end);
cap->setNodeId(0);
//WIP: new function for pushing this nodeid straightaway

ConstTaggedRegVal ctrv;
ctrv.setTag(true);
ctrv.getRegVal().rawCapVal() = (uint128_t)*cap;
isa[0]->setTaggedMiscReg(1, ctrv); //capmiscreg_cinit
//we don't actually support multithreading yet
for (ThreadID tid = 0; tid < numThreads; ++tid) {
Cap *cap = new Cap;
cap->setPerm(CapPerm::RWX);
cap->setType(CapType::LIN);
cap->setBound(secure_base, secure_end);
cap->setNodeId(0);
iew.ncQueue.allocateInit(tid);

ConstTaggedRegVal ctrv;
ctrv.setTag(true);
ctrv.getRegVal().rawCapVal() = (uint128_t)*cap;
isa[tid]->setTaggedMiscReg(1, ctrv); //capmiscreg_cinit
}
}

void
Expand Down
5 changes: 5 additions & 0 deletions src/arch/riscvcapstone/o3/ncq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ NCQ::squash(const InstSeqNum& squashed_num, ThreadID thread_id) {
threads[thread_id].squash(squashed_num);
}

void NCQ::allocateInit(ThreadID thread_id) {
assert(thread_id >= 0 && thread_id < threadNum);
threads[thread_id].allocateInit();
}

}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/arch/riscvcapstone/o3/ncq.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class NCQ {
void squash(const InstSeqNum& squashed_num, ThreadID thread_id);

Fault postExecCheck(const DynInstPtr& inst);

void allocateInit(ThreadID thread_id);
};

}
Expand Down
32 changes: 32 additions & 0 deletions src/arch/riscvcapstone/o3/ncq_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ namespace o3 {

class CPU;

const Addr NODE_MEM_BASE_ADDR = 0x7d0000000ULL;

inline Addr node_addr(NodeID node_id) {
return (Addr)(NODE_MEM_BASE_ADDR + ((Addr)node_id * (sizeof(Node))));
}

NCQUnit::NCQUnit(ThreadID thread_id, int queue_size,
CPU* cpu, NCQ* ncq, IEW* iew) :
threadId(thread_id),
Expand Down Expand Up @@ -273,6 +279,32 @@ NCQUnit::squash(const InstSeqNum &squashed_num) {
}
}

void
NCQUnit::allocateInit() {
Node init_node;
init_node.counter = 1;
init_node.depth = 0;
init_node.state = Node::VALID;
init_node.prev = NODE_ID_INVALID;
init_node.next = NODE_ID_INVALID;

Addr addr = node_addr(0);
RequestPtr req = std::make_shared<Request>();
req->requestorId(cpu->dataRequestorId());
req->setPaddr(addr);
req->setSize(sizeof(Node));
PacketPtr pkt = Packet::createWrite(req);
//pkt->setSize(sizeof(Node));
pkt->allocate();
memcpy(pkt->getPtr<void>(), &init_node, sizeof(Node));

cpu->nodeController.setRoot(0);

if(pkt) {
ncq->trySendPacket(pkt, threadId);
}
}


}
}
Expand Down
3 changes: 3 additions & 0 deletions src/arch/riscvcapstone/o3/ncq_unit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class NCQUnit {
Fault postExecCheck(const DynInstPtr& inst) {
return NoFault;
}

// allocate the node for cinit, assumed 0
void allocateInit();
};

}
Expand Down

0 comments on commit 637aa11

Please sign in to comment.