mvm: Add state management groundwork
Signed-off-by: Chloe M. <chloe@mirocom.org>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Mirocom Laboratories and MSP engineers.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include "mvm/state.h"
|
||||
#include "mvm/common.h"
|
||||
|
||||
int
|
||||
mvm_state_init(struct mvm_state *state)
|
||||
{
|
||||
if (state == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bus_ctl_init(&state->busctl) < 0) {
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mvm_rom_init(&state->bootrom, MVM_BOOTROM_SIZE) < 0) {
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
mvm_state_free(struct mvm_state *state)
|
||||
{
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
bus_ctl_free(&state->busctl);
|
||||
mvm_rom_free(&state->bootrom);
|
||||
}
|
||||
Reference in New Issue
Block a user