Skip to content

Commit

Permalink
Some nits to the smoke test.
Browse files Browse the repository at this point in the history
* Adds `extern C` to the header files in case of C++.
* Removes an unused variable.
  • Loading branch information
zhalvorsen authored and jhand2 committed Jul 3, 2024
1 parent 78d06a8 commit eb80750
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions hw-model/c-binding/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fn main() {
let config = cbindgen::Config {
header: Some(String::from_str("// Licensed under the Apache-2.0 license").unwrap()),
language: cbindgen::Language::C,
include_guard: Some("HW_MODEL_C_BINDING_OUT_CALIPTRA_MODEL_H".to_string()),
cpp_compat: true,
..Default::default()
};

Expand Down
3 changes: 0 additions & 3 deletions hw-model/c-binding/examples/api/caliptra_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ int caliptra_mailbox_execute(struct caliptra_model *model, uint32_t cmd, struct
return -EIO;
}

// Read Mbox out Data Len
uint32_t dlen = caliptra_mbox_read_dlen(model);

// Read Buffer
caliptra_mailbox_read_buffer(model, mbox_rx_buffer);

Expand Down
8 changes: 8 additions & 0 deletions hw-model/c-binding/examples/api/caliptra_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ struct caliptra_fuses {
enum DeviceLifecycle life_cycle;
};

#ifdef __cplusplus
extern "C" {
#endif

// Initialize Caliptra fuses prior to boot
int caliptra_init_fuses(struct caliptra_model *model, struct caliptra_fuses *fuses);

Expand All @@ -39,4 +43,8 @@ int caliptra_upload_fw(struct caliptra_model *model, struct caliptra_buffer *fw_
// Execute Mailbox Command
int caliptra_mailbox_execute(struct caliptra_model *model, uint32_t cmd, struct caliptra_buffer *mbox_tx_buffer, struct caliptra_buffer *mbox_rx_buffer);

#ifdef __cplusplus
}
#endif

#endif // CALIPTRA_API_H
7 changes: 7 additions & 0 deletions hw-model/c-binding/examples/api/caliptra_fuses.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// SOC FW MUST HAVE NO ACCESS TO THOSE APIS.
// A HW STATE MACHINE SHOULD BE USED TO SEND FUSE VALUES TO CALIPTRA OVER APB BUS

#ifdef __cplusplus
extern "C" {
#endif

static inline void caliptra_fuse_write(caliptra_model *model, uint32_t offset, uint32_t data)
{
caliptra_model_apb_write_u32(model, (offset + CALIPTRA_TOP_REG_GENERIC_AND_FUSE_REG_BASE_ADDR), data);
Expand All @@ -22,5 +26,8 @@ static inline void caliptra_fuse_array_write(caliptra_model *model, uint32_t off
caliptra_fuse_write(model, (offset + (idx * sizeof(uint32_t))), data[idx]);
}

#ifdef __cplusplus
}
#endif

#endif
7 changes: 7 additions & 0 deletions hw-model/c-binding/examples/api/caliptra_mbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <caliptra_top_reg.h>
#include "caliptra_api.h"

#ifdef __cplusplus
extern "C" {
#endif

static inline void caliptra_mbox_write(caliptra_model *model, uint32_t offset, uint32_t data)
{
caliptra_model_apb_write_u32(model, (offset + CALIPTRA_TOP_REG_MBOX_CSR_BASE_ADDR), data);
Expand Down Expand Up @@ -52,6 +56,9 @@ static inline void caliptra_mbox_write_dlen(caliptra_model *model, uint32_t dlen
caliptra_mbox_write(model, MBOX_CSR_MBOX_DLEN, dlen);
}

#ifdef __cplusplus
}
#endif

#define CALIPTRA_MBOX_STATUS_BUSY 0
#define CALIPTRA_MBOX_STATUS_DATA_READY 1
Expand Down

0 comments on commit eb80750

Please sign in to comment.