mirror of
https://github.com/buserror/mii_emu.git
synced 2024-11-25 05:32:20 +00:00
bank: Added mii_bank_dispose()
Also added a mode for the callback that will be called with NULL on exit Signed-off-by: Michel Pollet <buserror@gmail.com>
This commit is contained in:
parent
8ff29a874f
commit
a4ac4c0049
@ -14,6 +14,23 @@
|
|||||||
#include "mii.h"
|
#include "mii.h"
|
||||||
#include "mii_bank.h"
|
#include "mii_bank.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
mii_bank_dispose(
|
||||||
|
mii_bank_t *bank)
|
||||||
|
{
|
||||||
|
if (bank->alloc)
|
||||||
|
free(bank->mem);
|
||||||
|
bank->mem = NULL;
|
||||||
|
bank->alloc = 0;
|
||||||
|
if (bank->access) {
|
||||||
|
// Allow callback to free anything it wants
|
||||||
|
for (int i = 0; i < bank->size; i++)
|
||||||
|
if (bank->access[i].cb)
|
||||||
|
bank->access[i].cb(NULL, bank->access[i].param, 0, NULL, false);
|
||||||
|
free(bank->access);
|
||||||
|
}
|
||||||
|
bank->access = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mii_bank_write(
|
mii_bank_write(
|
||||||
|
@ -11,6 +11,18 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct mii_bank_t;
|
struct mii_bank_t;
|
||||||
|
/*
|
||||||
|
* Bank access callback can be register with banks and will be called
|
||||||
|
* when a specific page (or pages) are read/written to.
|
||||||
|
* Parameter will be the bank specified, the 'real' address beind read/written
|
||||||
|
* and the 'param' passed when the callback was registered.
|
||||||
|
* The callback should return true if it handled the access, false otherwise.
|
||||||
|
* If it return true, the bank will not be accessed for this read/write.
|
||||||
|
*
|
||||||
|
* Note: the callback will be called once with bank == NULL when the bank
|
||||||
|
* is being disposed, this allow any memory allocated by the callback to be
|
||||||
|
* freed.
|
||||||
|
*/
|
||||||
typedef bool (*mii_bank_access_cb)(
|
typedef bool (*mii_bank_access_cb)(
|
||||||
struct mii_bank_t *bank,
|
struct mii_bank_t *bank,
|
||||||
void *param,
|
void *param,
|
||||||
@ -33,6 +45,9 @@ typedef struct mii_bank_t {
|
|||||||
uint8_t *mem;
|
uint8_t *mem;
|
||||||
} mii_bank_t;
|
} mii_bank_t;
|
||||||
|
|
||||||
|
void
|
||||||
|
mii_bank_dispose(
|
||||||
|
mii_bank_t *bank);
|
||||||
void
|
void
|
||||||
mii_bank_write(
|
mii_bank_write(
|
||||||
mii_bank_t *bank,
|
mii_bank_t *bank,
|
||||||
|
Loading…
Reference in New Issue
Block a user