2014-11-08 01:54:59 +03:00
|
|
|
/* i/n/e.h
|
2014-09-22 20:10:57 +04:00
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
2014-11-05 03:29:08 +03:00
|
|
|
/** Data structures.
|
|
|
|
**/
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_line: control line.
|
2014-11-05 03:29:08 +03:00
|
|
|
*/
|
2014-11-06 03:20:01 +03:00
|
|
|
typedef struct _u3e_line {
|
2014-11-05 03:29:08 +03:00
|
|
|
c3_w pag_w;
|
|
|
|
c3_w mug_w;
|
2014-11-06 03:20:01 +03:00
|
|
|
} u3e_line;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_control: memory change, control file.
|
2014-11-05 03:29:08 +03:00
|
|
|
*/
|
2014-11-06 03:20:01 +03:00
|
|
|
typedef struct _u3e_control {
|
2014-11-05 03:29:08 +03:00
|
|
|
c3_d evt_d; // event number
|
|
|
|
c3_w nor_w; // new page count north
|
|
|
|
c3_w sou_w; // new page count south
|
|
|
|
c3_w pgs_w; // number of changed pages
|
2014-11-26 04:31:11 +03:00
|
|
|
u3e_line mem_u[0]; // per page
|
2014-11-06 03:20:01 +03:00
|
|
|
} u3e_control;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
|
|
|
/* u3_cs_patch: memory change, top level.
|
|
|
|
*/
|
|
|
|
typedef struct _u3_cs_patch {
|
|
|
|
c3_i ctl_i;
|
|
|
|
c3_i mem_i;
|
2014-11-06 03:20:01 +03:00
|
|
|
u3e_control* con_u;
|
2014-11-08 01:54:59 +03:00
|
|
|
} u3_ce_patch;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_image: memory segment, open file.
|
2014-11-05 03:29:08 +03:00
|
|
|
*/
|
2014-11-06 03:20:01 +03:00
|
|
|
typedef struct _u3e_image {
|
2014-11-05 03:29:08 +03:00
|
|
|
c3_c* nam_c; // segment name
|
|
|
|
c3_i fid_i; // open file, or 0
|
|
|
|
c3_w pgs_w; // length in pages
|
2014-11-06 03:20:01 +03:00
|
|
|
} u3e_image;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_pool: entire memory system.
|
2014-11-05 03:29:08 +03:00
|
|
|
*/
|
2014-11-06 03:20:01 +03:00
|
|
|
typedef struct _u3e_pool {
|
2014-11-16 04:10:15 +03:00
|
|
|
c3_c* dir_c; // path to
|
2014-11-05 03:29:08 +03:00
|
|
|
c3_d evt_d; // last patch written at event
|
2014-11-06 03:20:01 +03:00
|
|
|
c3_w dit_w[u3a_pages >> 5]; // touched since last save
|
|
|
|
u3e_image nor_u; // north segment
|
|
|
|
u3e_image sou_u; // south segment
|
|
|
|
} u3e_pool;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
/** Globals.
|
|
|
|
**/
|
|
|
|
/* u3_Pool / u3P: global memory control.
|
|
|
|
*/
|
2014-11-08 01:54:59 +03:00
|
|
|
c3_global u3e_pool u3e_Pool;
|
|
|
|
# define u3P u3e_Pool
|
2014-11-05 03:29:08 +03:00
|
|
|
|
|
|
|
|
2014-09-22 20:10:57 +04:00
|
|
|
/** Functions.
|
|
|
|
**/
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_fault(): handle a memory event with libsigsegv protocol.
|
2014-09-22 20:10:57 +04:00
|
|
|
*/
|
2014-09-23 21:11:59 +04:00
|
|
|
c3_i
|
2014-11-06 03:20:01 +03:00
|
|
|
u3e_fault(void* adr_v, c3_i ser_i);
|
2014-09-22 20:10:57 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_save():
|
2014-09-22 20:10:57 +04:00
|
|
|
*/
|
2014-09-23 21:11:59 +04:00
|
|
|
void
|
2014-11-06 03:20:01 +03:00
|
|
|
u3e_save(void);
|
2014-09-22 20:10:57 +04:00
|
|
|
|
2014-11-20 03:46:16 +03:00
|
|
|
/* u3e_live(): start the persistence system. Return c3y if no image.
|
2014-11-16 04:10:15 +03:00
|
|
|
*/
|
2014-11-20 03:46:16 +03:00
|
|
|
c3_o
|
2014-11-16 04:10:15 +03:00
|
|
|
u3e_live(c3_o nuu_o, c3_c* dir_c);
|
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_dirty(): count dirty pages.
|
2014-11-02 01:13:18 +03:00
|
|
|
*/
|
|
|
|
c3_w
|
2014-11-06 03:20:01 +03:00
|
|
|
u3e_dirty(void);
|
2014-11-05 03:29:08 +03:00
|
|
|
|