Skip to content

Commit 862bd76

Browse files
author
Jordi Chauzi
committed
dpu: lldb: updating dpu host api result enum
1 parent 0078f31 commit 862bd76

File tree

5 files changed

+44
-44
lines changed

5 files changed

+44
-44
lines changed

lldb/packages/Python/lldbsuite/test/dpu/dpu_list/host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
int main() {
44
struct dpu_set_t set;
55

6-
if (dpu_alloc(1, "backend=hw,cycleAccurate=true", &set) != DPU_API_SUCCESS) {
6+
if (dpu_alloc(1, "backend=hw,cycleAccurate=true", &set) != DPU_OK) {
77
DPU_ASSERT(dpu_alloc(1, "backend=simulator", &set));
88
}
99

lldb/source/Plugins/Process/Dpu/Dpu.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ bool Dpu::LoadElf(const FileSpec &elf_file_path) {
117117
ModuleSP elf_mod(new Module(elf_file_path, k_dpu_arch));
118118

119119
struct dpu_set_t set = dpu_set_from_dpu(m_dpu);
120-
dpu_api_status_t status = dpu_load(set, elf_file_path.GetCString(), NULL);
121-
if (status != DPU_API_SUCCESS)
120+
dpu_result_t status = dpu_load(set, elf_file_path.GetCString(), NULL);
121+
if (status != DPU_OK)
122122
return false;
123123

124124
if (!SetPrintfSequenceAddrsFromRuntimeInfo())
@@ -151,12 +151,12 @@ bool Dpu::Boot() {
151151
sizeof(dpuinstruction_t));
152152

153153
int res = dpu_custom_for_dpu(m_dpu, DPU_COMMAND_DPU_PREEXECUTION, NULL);
154-
if (res != DPU_API_SUCCESS)
154+
if (res != DPU_OK)
155155
return false;
156156

157157
bool ignored;
158158
res = dpu_launch_thread_on_dpu(m_dpu, DPU_BOOT_THREAD, false, &ignored);
159-
if (res != DPU_API_SUCCESS)
159+
if (res != DPU_OK)
160160
return false;
161161

162162
dpu_is_running = true;
@@ -245,10 +245,10 @@ bool Dpu::ResumeThreads(llvm::SmallVector<uint32_t, 8> *resume_list,
245245
if (!m_context->ContextReadyForResumeOrStep())
246246
return false;
247247

248-
int ret = DPU_API_SUCCESS;
248+
int ret = DPU_OK;
249249
if (registers_has_been_modified) {
250250
ret = dpu_restore_context_for_dpu(m_dpu, m_context->Get());
251-
if (ret != DPU_API_SUCCESS)
251+
if (ret != DPU_OK)
252252
return false;
253253
registers_has_been_modified = false;
254254
}
@@ -310,7 +310,7 @@ bool Dpu::PrepareStepOverPrintfBkp(
310310
if (stdout_file != NULL) {
311311
if (dpulog_read_and_display_contents_of(mram_buffer, mram_buffer_size,
312312
stdout_file) !=
313-
DPU_API_SUCCESS) {
313+
DPU_OK) {
314314
goto PrepareStepOverPrintfBkp_err;
315315
}
316316

@@ -343,10 +343,10 @@ StateType Dpu::StepThread(uint32_t thread_index, unsigned int *exit_status) {
343343
if (!m_context->ScheduledThread(thread_index))
344344
return StateType::eStateStopped;
345345

346-
int ret = DPU_API_SUCCESS;
346+
int ret = DPU_OK;
347347
if (registers_has_been_modified) {
348348
ret = dpu_restore_context_for_dpu(m_dpu, m_context->Get());
349-
if (ret != DPU_API_SUCCESS)
349+
if (ret != DPU_OK)
350350
return StateType::eStateCrashed;
351351
registers_has_been_modified = false;
352352
}
@@ -383,7 +383,7 @@ StateType Dpu::StepThread(uint32_t thread_index, unsigned int *exit_status) {
383383
return StateType::eStateCrashed;
384384
}
385385

386-
if (ret != DPU_API_SUCCESS)
386+
if (ret != DPU_OK)
387387
return StateType::eStateCrashed;
388388
if (!m_context->DpuIsRunning()) {
389389
*exit_status = m_context->GetExitStatus();
@@ -395,13 +395,13 @@ StateType Dpu::StepThread(uint32_t thread_index, unsigned int *exit_status) {
395395
bool Dpu::WriteWRAM(uint32_t offset, const void *buf, size_t size) {
396396
std::lock_guard<std::recursive_mutex> guard(m_rank->GetLock());
397397

398-
dpu_api_status_t ret;
398+
dpu_result_t ret;
399399
// fast path, everything is aligned
400400
if (((offset & dpuword_size_mod) == 0) && ((size & dpuword_size_mod) == 0)) {
401401
const dpuword_t *words = static_cast<const dpuword_t *>(buf);
402402
ret = dpu_copy_to_wram_for_dpu(m_dpu, offset / sizeof(dpuword_t), words,
403403
size / sizeof(dpuword_t));
404-
return ret == DPU_API_SUCCESS;
404+
return ret == DPU_OK;
405405
}
406406

407407
// slow path
@@ -426,7 +426,7 @@ bool Dpu::WriteWRAM(uint32_t offset, const void *buf, size_t size) {
426426
ret =
427427
dpu_copy_from_wram_for_dpu(m_dpu, words, final_offset / sizeof(dpuword_t),
428428
final_size / sizeof(dpuword_t));
429-
if (ret != DPU_API_SUCCESS) {
429+
if (ret != DPU_OK) {
430430
delete[] words;
431431
return false;
432432
}
@@ -439,14 +439,14 @@ bool Dpu::WriteWRAM(uint32_t offset, const void *buf, size_t size) {
439439
final_size / sizeof(dpuword_t));
440440

441441
delete[] words;
442-
return ret == DPU_API_SUCCESS;
442+
return ret == DPU_OK;
443443
}
444444

445445
bool Dpu::ReadWRAM(uint32_t offset, void *buf, size_t size) {
446446
std::lock_guard<std::recursive_mutex> guard(m_rank->GetLock());
447447
dpuword_t *words = static_cast<dpuword_t *>(buf);
448448

449-
dpu_api_status_t ret;
449+
dpu_result_t ret;
450450
size_t final_size =
451451
size + sizeof(dpuword_t) - 1 + (offset & dpuword_size_mod);
452452

@@ -470,20 +470,20 @@ bool Dpu::ReadWRAM(uint32_t offset, void *buf, size_t size) {
470470
ret = dpu_copy_from_wram_for_dpu(m_dpu, words, offset / sizeof(dpuword_t),
471471
size / sizeof(dpuword_t));
472472
}
473-
return ret == DPU_API_SUCCESS;
473+
return ret == DPU_OK;
474474
}
475475

476476
bool Dpu::WriteIRAM(uint32_t offset, const void *buf, size_t size) {
477477
std::lock_guard<std::recursive_mutex> guard(m_rank->GetLock());
478478

479-
dpu_api_status_t ret;
479+
dpu_result_t ret;
480480
// fast path, everything is aligned
481481
if (((offset & instruction_size_mod) == 0) &&
482482
((size & instruction_size_mod) == 0)) {
483483
const dpuinstruction_t *instrs = static_cast<const dpuinstruction_t *>(buf);
484484
ret = dpu_copy_to_iram_for_dpu(m_dpu, offset / sizeof(dpuinstruction_t),
485485
instrs, size / sizeof(dpuinstruction_t));
486-
return ret == DPU_API_SUCCESS;
486+
return ret == DPU_OK;
487487
}
488488

489489
// slow path
@@ -508,7 +508,7 @@ bool Dpu::WriteIRAM(uint32_t offset, const void *buf, size_t size) {
508508
ret = dpu_copy_from_iram_for_dpu(m_dpu, instrs,
509509
final_offset / sizeof(dpuinstruction_t),
510510
final_size / sizeof(dpuinstruction_t));
511-
if (ret != DPU_API_SUCCESS) {
511+
if (ret != DPU_OK) {
512512
delete[] instrs;
513513
return false;
514514
}
@@ -521,14 +521,14 @@ bool Dpu::WriteIRAM(uint32_t offset, const void *buf, size_t size) {
521521
instrs, final_size / sizeof(dpuinstruction_t));
522522

523523
delete[] instrs;
524-
return ret == DPU_API_SUCCESS;
524+
return ret == DPU_OK;
525525
}
526526

527527
bool Dpu::ReadIRAM(uint32_t offset, void *buf, size_t size) {
528528
std::lock_guard<std::recursive_mutex> guard(m_rank->GetLock());
529529
dpuinstruction_t *instrs = static_cast<dpuinstruction_t *>(buf);
530530

531-
dpu_api_status_t ret;
531+
dpu_result_t ret;
532532
size_t final_size =
533533
size + sizeof(dpuinstruction_t) - 1 + (offset & instruction_size_mod);
534534

@@ -554,23 +554,23 @@ bool Dpu::ReadIRAM(uint32_t offset, void *buf, size_t size) {
554554
offset / sizeof(dpuinstruction_t),
555555
size / sizeof(dpuinstruction_t));
556556
}
557-
return ret == DPU_API_SUCCESS;
557+
return ret == DPU_OK;
558558
}
559559

560560
bool Dpu::WriteMRAM(uint32_t offset, const void *buf, size_t size) {
561561
std::lock_guard<std::recursive_mutex> guard(m_rank->GetLock());
562562
const uint8_t *bytes = static_cast<const uint8_t *>(buf);
563563

564-
dpu_api_status_t ret = dpu_copy_to_mram(m_dpu, offset, bytes, size, 0);
565-
return ret == DPU_API_SUCCESS;
564+
dpu_result_t ret = dpu_copy_to_mram(m_dpu, offset, bytes, size, 0);
565+
return ret == DPU_OK;
566566
}
567567

568568
bool Dpu::ReadMRAM(uint32_t offset, void *buf, size_t size) {
569569
std::lock_guard<std::recursive_mutex> guard(m_rank->GetLock());
570570
uint8_t *bytes = static_cast<uint8_t *>(buf);
571571

572-
dpu_api_status_t ret = dpu_copy_from_mram(m_dpu, bytes, offset, size, 0);
573-
return ret == DPU_API_SUCCESS;
572+
dpu_result_t ret = dpu_copy_from_mram(m_dpu, bytes, offset, size, 0);
573+
return ret == DPU_OK;
574574
}
575575

576576
bool Dpu::AllocIRAMBuffer(uint8_t **iram, uint32_t *iram_size) {
@@ -596,24 +596,24 @@ bool Dpu::GenerateSaveCore(const char *exe_path, const char *core_file_path,
596596
uint8_t *wram = new uint8_t[wram_size];
597597
uint8_t *mram = new uint8_t[mram_size];
598598

599-
dpu_api_status_t status;
599+
dpu_result_t status;
600600
if (wram != NULL && mram != NULL) {
601601
status = dpu_copy_from_wram_for_dpu(m_dpu, (dpuword_t *)wram, 0,
602602
nb_word_in_wram);
603-
if (status != DPU_API_SUCCESS)
603+
if (status != DPU_OK)
604604
goto dpu_generate_save_core_exit;
605605
status = dpu_copy_from_mram(m_dpu, mram, 0, mram_size, DPU_PRIMARY_MRAM);
606-
if (status != DPU_API_SUCCESS)
606+
if (status != DPU_OK)
607607
goto dpu_generate_save_core_exit;
608608

609609
status =
610610
dpu_create_core_dump(rank, exe_path, core_file_path, m_context->Get(),
611611
wram, mram, iram, wram_size, mram_size, iram_size);
612-
if (status != DPU_API_SUCCESS)
612+
if (status != DPU_OK)
613613
goto dpu_generate_save_core_exit;
614614

615615
} else {
616-
status = DPU_API_SYSTEM_ERROR;
616+
status = DPU_ERR_SYSTEM;
617617
}
618618

619619
dpu_generate_save_core_exit:
@@ -695,7 +695,7 @@ unsigned int Dpu::GetDpuID() { return dpu_get_member_id(m_dpu); }
695695

696696
bool Dpu::SaveSliceContext(uint64_t structure_value, uint64_t slice_target,
697697
dpu_bitfield_t host_mux_mram_state) {
698-
bool success = dpu_save_slice_context_for_dpu(m_dpu) == DPU_API_SUCCESS;
698+
bool success = dpu_save_slice_context_for_dpu(m_dpu) == DPU_OK;
699699
if (!success)
700700
return false;
701701

@@ -705,7 +705,7 @@ bool Dpu::SaveSliceContext(uint64_t structure_value, uint64_t slice_target,
705705
}
706706

707707
bool Dpu::RestoreSliceContext() {
708-
return dpu_restore_slice_context_for_dpu(m_dpu) == DPU_API_SUCCESS;
708+
return dpu_restore_slice_context_for_dpu(m_dpu) == DPU_OK;
709709
}
710710

711711
void Dpu::SetAttachSession() { attach_session = true; }

lldb/source/Plugins/Process/Dpu/DpuContext.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ bool DpuContext::StopThreads() {
8282
m_context->dma_fault = false;
8383
m_context->mem_fault = false;
8484

85-
int ret = DPU_API_SUCCESS;
85+
int ret = DPU_OK;
8686
ret = dpu_initialize_fault_process_for_dpu(m_dpu, m_context);
87-
if (ret != DPU_API_SUCCESS)
87+
if (ret != DPU_OK)
8888
return false;
8989
ret = dpu_extract_context_for_dpu(m_dpu, m_context);
9090

9191
UpdateRunningThreads();
9292

93-
return ret == DPU_API_SUCCESS;
93+
return ret == DPU_OK;
9494
}
9595

9696
bool DpuContext::ResumeThreads(llvm::SmallVector<uint32_t, 8> *resume_list) {
@@ -113,17 +113,17 @@ bool DpuContext::ResumeThreads(llvm::SmallVector<uint32_t, 8> *resume_list) {
113113
}
114114

115115
return dpu_finalize_fault_process_for_dpu(m_dpu, m_context) ==
116-
DPU_API_SUCCESS;
116+
DPU_OK;
117117
}
118118

119-
dpu_api_status_t DpuContext::StepThread(uint32_t thread_index) {
119+
dpu_result_t DpuContext::StepThread(uint32_t thread_index) {
120120
ResetScheduling();
121121
ResetLastResumeThreads();
122122
AddThreadInScheduling(thread_index);
123123

124-
dpu_api_status_t ret =
124+
dpu_result_t ret =
125125
dpu_execute_thread_step_in_fault_for_dpu(m_dpu, thread_index, m_context);
126-
if (ret != DPU_API_SUCCESS)
126+
if (ret != DPU_OK)
127127
return ret;
128128
ret = dpu_extract_context_for_dpu(m_dpu, m_context);
129129

lldb/source/Plugins/Process/Dpu/DpuContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class DpuContext {
5050

5151
bool StopThreads();
5252
bool ResumeThreads(llvm::SmallVector<uint32_t, 8> *resume_list);
53-
dpu_api_status_t StepThread(uint32_t thread_index);
53+
dpu_result_t StepThread(uint32_t thread_index);
5454

5555
unsigned int GetExitStatus();
5656
lldb::addr_t GetPcOfThread(dpu_thread_t thread);

lldb/source/Plugins/Process/Dpu/DpuRank.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool DpuRank::Open(char *profile, FILE *stdout_file) {
4747
std::lock_guard<std::recursive_mutex> guard(m_lock);
4848

4949
int ret = dpu_get_rank_of_type(profile, &m_rank);
50-
if (ret != DPU_API_SUCCESS)
50+
if (ret != DPU_OK)
5151
return false;
5252
m_desc = dpu_get_description(m_rank);
5353

@@ -67,7 +67,7 @@ bool DpuRank::IsValid() { return m_rank ? true : false; }
6767

6868
bool DpuRank::Reset() {
6969
std::lock_guard<std::recursive_mutex> guard(m_lock);
70-
return dpu_reset_rank(m_rank) == DPU_API_SUCCESS;
70+
return dpu_reset_rank(m_rank) == DPU_OK;
7171
}
7272

7373
Dpu *DpuRank::GetDpuFromSliceIdAndDpuId(unsigned int slice_id,

0 commit comments

Comments
 (0)