Skip to content

Commit

Permalink
thor: Add a GetNumCpu request to kerncfg
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke committed Sep 23, 2024
1 parent 6107613 commit c2e1332
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions kernel/thor/generic/kerncfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ struct KerncfgBusObject : private KernelBusObject {
auto respError = co_await SendBufferSender{lane, std::move(respBuffer)};
if(respError != Error::success)
co_return respError;
}else if(preamble.id() == bragi::message_id<managarm::kerncfg::GetNumCpuRequest>) {
auto req = bragi::parse_head_only<managarm::kerncfg::GetNumCpuRequest>(reqBuffer, *kernelAlloc);

if (!req) {
co_return Error::protocolViolation;
}

managarm::kerncfg::GetNumCpuResponse<KernelAlloc> resp(*kernelAlloc);
resp.set_error(managarm::kerncfg::Error::SUCCESS);
resp.set_num_cpu(getCpuCount());

frg::unique_memory<KernelAlloc> respBuffer{*kernelAlloc, resp.size_of_head()};
bragi::write_head_only(resp, respBuffer);
auto respError = co_await SendBufferSender{lane, std::move(respBuffer)};
if(respError != Error::success) {
co_return respError;
}
}else{
managarm::kerncfg::SvrResponse<KernelAlloc> resp(*kernelAlloc);
resp.set_error(managarm::kerncfg::Error::ILLEGAL_REQUEST);
Expand Down
10 changes: 10 additions & 0 deletions protocols/kerncfg/kerncfg.bragi
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ head(128):
uint64 available_memory;
uint64 memory_unit;
}

message GetNumCpuRequest 6 {
head(128):
}

message GetNumCpuResponse 7 {
head(128):
Error error;
uint64 num_cpu;
}

0 comments on commit c2e1332

Please sign in to comment.