HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
pbank.c File Reference
#include <string.h>
#include <hipc/atomic.h>
#include <hipc/pbank.h>
Include dependency graph for pbank.c:

Go to the source code of this file.

Functions

void hipcPbankInit (struct HIPC_pbank *const bank_p, void *const buf_p, const size_t page_size)
 Initializes a parameter bank. More...
 
size_t hipcPbankGetPageSize (struct HIPC_pbank *const bank_p)
 Gets page size. More...
 
const void * hipcPbankGetReadOnlyPage (struct HIPC_pbank *const bank_p)
 Gets a current read only page. More...
 
void * hipcPbankGetWritablePage (struct HIPC_pbank *const bank_p)
 Gets a current writable page. More...
 
enum HIPC_pbank_stat hipcPbankGetStat (struct HIPC_pbank *const bank_p)
 Gets current status of a bank. More...
 
enum HIPC_errno hipcPbankSwitchRequest (struct HIPC_pbank *const bank_p)
 Requests to switch pages. More...
 
int hipcPbankSwitchAccept (struct HIPC_pbank *const bank_p)
 Accepts a switching request and switches pages if switching is requested. More...
 
enum HIPC_errno hipcPbankSwitchComplete (struct HIPC_pbank *const bank_p)
 Makes both pages have the same latest contents and completes the switching. More...
 
enum HIPC_errno hipcPbankSwitchReqWaitCmpl (struct HIPC_pbank *const bank_p)
 Calls hipcPbankSwitchRequest(), waits for acceptance of the request, and calls hipcPbankSwitchComplete(). More...
 

Function Documentation

void hipcPbankInit ( struct HIPC_pbank *const  bank_p,
void *const  buf_p,
const size_t  page_size 
)

Initializes a parameter bank.

This function copies contents in the first half of buffer to the second half.

Parameters
bank_ppointer to a parameter bank
buf_pa buffer whose size must be page_size multiplied by 2
page_sizesize of a page

Definition at line 14 of file pbank.c.

References HIPC_MEM_BARRIER, HIPC_PBANK_STAT_GROUND, HIPC_pbank::page_ro_p, HIPC_pbank::page_rw_p, HIPC_pbank::page_size, and HIPC_pbank::stat.

size_t hipcPbankGetPageSize ( struct HIPC_pbank *const  bank_p)

Gets page size.

Parameters
bank_ppointer to a parameter bank
Returns
page size

Definition at line 33 of file pbank.c.

References HIPC_pbank::page_size.

const void* hipcPbankGetReadOnlyPage ( struct HIPC_pbank *const  bank_p)

Gets a current read only page.

Parameters
bank_ppointer to a parameter bank
Returns
current read only page

Definition at line 44 of file pbank.c.

References HIPC_pbank::page_ro_p.

void* hipcPbankGetWritablePage ( struct HIPC_pbank *const  bank_p)

Gets a current writable page.

Parameters
bank_ppointer to a parameter bank
Returns
current writable page

Definition at line 55 of file pbank.c.

References HIPC_pbank::page_rw_p.

enum HIPC_pbank_stat hipcPbankGetStat ( struct HIPC_pbank *const  bank_p)

Gets current status of a bank.

Parameters
bank_ppointer to a parameter bank
Returns
current status

Definition at line 66 of file pbank.c.

References HIPC_pbank::stat.

Referenced by hipcPbankSwitchReqWaitCmpl().

Here is the caller graph for this function:

enum HIPC_errno hipcPbankSwitchRequest ( struct HIPC_pbank *const  bank_p)

Requests to switch pages.

Parameters
bank_ppointer to a parameter bank
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 77 of file pbank.c.

References HIPC_ERR_S_PBANK_STAT_MISMATCH, HIPC_MEM_BARRIER, HIPC_PBANK_STAT_GROUND, HIPC_PBANK_STAT_REQUESTED, HIPC_SUCCESS, and HIPC_pbank::stat.

Referenced by hipcPbankSwitchReqWaitCmpl().

Here is the caller graph for this function:

int hipcPbankSwitchAccept ( struct HIPC_pbank *const  bank_p)

Accepts a switching request and switches pages if switching is requested.

Parameters
bank_ppointer to a parameter bank
Return values
0Switching is not requested.
1Pages have been switched.

Definition at line 96 of file pbank.c.

References HIPC_MEM_BARRIER, HIPC_PBANK_STAT_ACCEPTED, HIPC_PBANK_STAT_REQUESTED, HIPC_pbank::page_ro_p, HIPC_pbank::page_rw_p, and HIPC_pbank::stat.

enum HIPC_errno hipcPbankSwitchComplete ( struct HIPC_pbank *const  bank_p)

Makes both pages have the same latest contents and completes the switching.

Parameters
bank_ppointer to a parameter bank
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 121 of file pbank.c.

References HIPC_ERR_S_PBANK_STAT_MISMATCH, HIPC_MEM_BARRIER, HIPC_PBANK_STAT_ACCEPTED, HIPC_PBANK_STAT_GROUND, HIPC_SUCCESS, HIPC_pbank::page_ro_p, HIPC_pbank::page_rw_p, HIPC_pbank::page_size, and HIPC_pbank::stat.

Referenced by hipcPbankSwitchReqWaitCmpl().

Here is the caller graph for this function:

enum HIPC_errno hipcPbankSwitchReqWaitCmpl ( struct HIPC_pbank *const  bank_p)

Calls hipcPbankSwitchRequest(), waits for acceptance of the request, and calls hipcPbankSwitchComplete().

Parameters
bank_ppointer to a parameter bank
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 141 of file pbank.c.

References HIPC_PBANK_STAT_REQUESTED, HIPC_SUCCESS, hipcPbankGetStat(), hipcPbankSwitchComplete(), and hipcPbankSwitchRequest().

Here is the call graph for this function: