From 50b7f13f9fbd498540451ca8c6411c6a364ce95c Mon Sep 17 00:00:00 2001 From: Cristiano Giuffrida Date: Tue, 11 Mar 2014 18:01:27 +0100 Subject: [PATCH] Add live update-friendly annotations. Change-Id: I7d7d79893836a20799ca548a350f3288e92581f0 --- minix/drivers/power/acpi/acpi.c | 14 ++++++++++++++ minix/fs/mfs/buf.h | 12 ++++++------ minix/fs/procfs/main.c | 2 +- minix/fs/procfs/tree.c | 10 +++++++--- minix/include/minix/const.h | 6 ++++++ minix/include/minix/ipc.h | 4 ++-- minix/include/minix/safecopies.h | 2 +- minix/include/minix/timers.h | 4 ++-- minix/kernel/proc.h | 4 ++-- minix/net/inet/generic/arp.c | 2 +- minix/net/inet/generic/event.h | 5 ++--- minix/net/inet/generic/ip.c | 1 + minix/net/inet/generic/ip_int.h | 4 +++- minix/net/inet/inet_config.c | 6 ++++-- minix/servers/devman/main.c | 4 ++-- minix/servers/ds/store.h | 4 ++-- minix/servers/is/dmp_ds.c | 6 +++--- minix/servers/rs/type.h | 3 ++- minix/servers/vfs/fproc.h | 1 + minix/servers/vfs/select.c | 4 +++- minix/servers/vm/pagetable.c | 6 +++--- minix/servers/vm/slaballoc.c | 10 ++++++---- 22 files changed, 74 insertions(+), 40 deletions(-) diff --git a/minix/drivers/power/acpi/acpi.c b/minix/drivers/power/acpi/acpi.c index a58c06243..6732b5529 100644 --- a/minix/drivers/power/acpi/acpi.c +++ b/minix/drivers/power/acpi/acpi.c @@ -100,8 +100,22 @@ void init_acpi(void) static int sef_cb_init_fresh(int type, sef_init_info_t *info) { + int r; + init_acpi(); + /* Let SEF know about ACPI special cache word. */ + r = sef_llvm_add_special_mem_region((void*)0xCACACACA, 1, + "%MMAP_CACHE_WORD"); + if(r < 0) { + printf("acpi: sef_llvm_add_special_mem_region failed %d\n", r); + } + + /* XXX To-do: acpi requires custom state transfer handlers for + * unions acpi_operand_object and acpi_generic_state (and nested unions) + * for generic state transfer to work correctly. + */ + return OK; } diff --git a/minix/fs/mfs/buf.h b/minix/fs/mfs/buf.h index 898095893..ce997668e 100644 --- a/minix/fs/mfs/buf.h +++ b/minix/fs/mfs/buf.h @@ -3,7 +3,7 @@ #include "clean.h" -union fsdata_u { +union ixfer_fsdata_u { char b__data[1]; /* ordinary user data */ struct direct b__dir[1]; /* directory block */ zone_t b__v2_ind[1]; /* V2 indirect block */ @@ -12,10 +12,10 @@ union fsdata_u { }; /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */ -#define b_data(b) ((union fsdata_u *) b->data)->b__data -#define b_dir(b) ((union fsdata_u *) b->data)->b__dir -#define b_v2_ind(b) ((union fsdata_u *) b->data)->b__v2_ind -#define b_v2_ino(b) ((union fsdata_u *) b->data)->b__v2_ino -#define b_bitmap(b) ((union fsdata_u *) b->data)->b__bitmap +#define b_data(b) ((union ixfer_fsdata_u *) b->data)->b__data +#define b_dir(b) ((union ixfer_fsdata_u *) b->data)->b__dir +#define b_v2_ind(b) ((union ixfer_fsdata_u *) b->data)->b__v2_ind +#define b_v2_ino(b) ((union ixfer_fsdata_u *) b->data)->b__v2_ino +#define b_bitmap(b) ((union ixfer_fsdata_u *) b->data)->b__bitmap #endif diff --git a/minix/fs/procfs/main.c b/minix/fs/procfs/main.c index 6ad523500..3f39382f7 100644 --- a/minix/fs/procfs/main.c +++ b/minix/fs/procfs/main.c @@ -68,7 +68,7 @@ init_hook(void) */ int main(void) { - struct inode_stat stat; + static struct inode_stat stat; int r; /* diff --git a/minix/fs/procfs/tree.c b/minix/fs/procfs/tree.c index cb977d328..4e859c71f 100644 --- a/minix/fs/procfs/tree.c +++ b/minix/fs/procfs/tree.c @@ -2,9 +2,13 @@ #include "inc.h" -struct proc proc[NR_PROCS + NR_TASKS]; -struct mproc mproc[NR_PROCS]; -struct fproc fproc[NR_PROCS]; +typedef struct proc ixfer_proc_t; +typedef struct fproc ixfer_fproc_t; +typedef struct mproc ixfer_mproc_t; + +ixfer_proc_t proc[NR_PROCS + NR_TASKS]; +ixfer_mproc_t mproc[NR_PROCS]; +ixfer_fproc_t fproc[NR_PROCS]; static int nr_pid_entries; diff --git a/minix/include/minix/const.h b/minix/include/minix/const.h index 5131e9a00..c69d76b71 100644 --- a/minix/include/minix/const.h +++ b/minix/include/minix/const.h @@ -30,6 +30,12 @@ #endif #endif +#ifndef _MINIX_MAGIC +#define __ALIGNED(X) __aligned(X) +#else +#define __ALIGNED(X) +#endif + #define EXTERN extern /* used in *.h files */ #define TRUE 1 /* used for turning integers into Booleans */ diff --git a/minix/include/minix/ipc.h b/minix/include/minix/ipc.h index 2f62a0a18..6f444d333 100644 --- a/minix/include/minix/ipc.h +++ b/minix/include/minix/ipc.h @@ -2024,7 +2024,7 @@ typedef struct { } mess_vmmcp_reply; _ASSERT_MSG_SIZE(mess_vmmcp_reply); -typedef struct { +typedef struct noxfer_message { endpoint_t m_source; /* who sent the message */ int m_type; /* what kind of message is it */ union { @@ -2254,7 +2254,7 @@ typedef struct { u8_t size[56]; /* message payload may have 56 bytes at most */ }; -} message __aligned(16); +} message __ALIGNED(16); /* Ensure the complete union respects the IPC assumptions. */ typedef int _ASSERT_message[/* CONSTCOND */sizeof(message) == 64 ? 1 : -1]; diff --git a/minix/include/minix/safecopies.h b/minix/include/minix/safecopies.h index 3f875614b..5fe730339 100644 --- a/minix/include/minix/safecopies.h +++ b/minix/include/minix/safecopies.h @@ -9,7 +9,7 @@ typedef struct { int cp_flags; /* CPF_* below */ - union { + union ixfer_cp_u{ struct { /* CPF_DIRECT */ endpoint_t cp_who_to; /* grantee */ diff --git a/minix/include/minix/timers.h b/minix/include/minix/timers.h index 44c039791..82f162fda 100644 --- a/minix/include/minix/timers.h +++ b/minix/include/minix/timers.h @@ -23,7 +23,7 @@ struct minix_timer; typedef void (*tmr_func_t)(struct minix_timer *tp); -typedef union { int ta_int; long ta_long; void *ta_ptr; } tmr_arg_t; +typedef union { int ta_int; long ta_long; void *ta_ptr; } ixfer_tmr_arg_t; /* A minix_timer_t variable must be declare for each distinct timer to be used. * The timers watchdog function and expiration time are automatically set @@ -34,7 +34,7 @@ typedef struct minix_timer struct minix_timer *tmr_next; /* next in a timer chain */ clock_t tmr_exp_time; /* expiration time */ tmr_func_t tmr_func; /* function to call when expired */ - tmr_arg_t tmr_arg; /* random argument */ + ixfer_tmr_arg_t tmr_arg; /* random argument */ } minix_timer_t; /* Used when the timer is not active. */ diff --git a/minix/kernel/proc.h b/minix/kernel/proc.h index f3115354e..559e35850 100644 --- a/minix/kernel/proc.h +++ b/minix/kernel/proc.h @@ -96,7 +96,7 @@ struct proc { #define VMSTYPE_MAP 3 int type; /* suspended operation */ - union { + union ixfer_saved{ /* VMSTYPE_SYS_MESSAGE */ message reqmsg; /* suspended request message */ } saved; @@ -104,7 +104,7 @@ struct proc { /* Parameters of request to VM */ int req_type; endpoint_t target; - union { + union ixfer_params{ struct { vir_bytes start, length; /* memory range */ u8_t writeflag; /* nonzero for write access */ diff --git a/minix/net/inet/generic/arp.c b/minix/net/inet/generic/arp.c index 6fe6ad4a8..38593b553 100644 --- a/minix/net/inet/generic/arp.c +++ b/minix/net/inet/generic/arp.c @@ -38,7 +38,7 @@ typedef struct arp46 ether_addr_t a46_dstaddr; ether_addr_t a46_srcaddr; ether_type_t a46_ethtype; - union + union ixfer_arp46_u { struct { diff --git a/minix/net/inet/generic/event.h b/minix/net/inet/generic/event.h index 568371268..f5afed7fa 100644 --- a/minix/net/inet/generic/event.h +++ b/minix/net/inet/generic/event.h @@ -13,13 +13,12 @@ Copyright 1995 Philip Homburg struct event; -typedef union ev_arg +typedef struct ev_arg { - int ev_int; void *ev_ptr; } ev_arg_t; -typedef void (*ev_func_t) ARGS(( struct event *ev, union ev_arg eva )); +typedef void (*ev_func_t) ARGS(( struct event *ev, ev_arg_t eva )); typedef struct event { diff --git a/minix/net/inet/generic/ip.c b/minix/net/inet/generic/ip.c index c41fef004..05792f643 100644 --- a/minix/net/inet/generic/ip.c +++ b/minix/net/inet/generic/ip.c @@ -80,6 +80,7 @@ void ip_init() ip_port->ip_dl_type= icp->ic_devtype; ip_port->ip_mtu= IP_DEF_MTU; ip_port->ip_mtu_max= IP_MAX_PACKSIZE; + memset(&ip_port->ip_dl, 0, sizeof(ip_port->ip_dl)); switch(ip_port->ip_dl_type) { diff --git a/minix/net/inet/generic/ip_int.h b/minix/net/inet/generic/ip_int.h index a1c8cf735..95fcaec4a 100644 --- a/minix/net/inet/generic/ip_int.h +++ b/minix/net/inet/generic/ip_int.h @@ -29,7 +29,7 @@ typedef struct ip_port { int ip_flags, ip_dl_type; int ip_port; - union + union sxfer_ip_dl_u { struct { @@ -45,9 +45,11 @@ typedef struct ip_port } dl_eth; struct { + int dummy_int[3]; int ps_port; acc_t *ps_send_head; acc_t *ps_send_tail; + void* dummy_ptr[3]; } dl_ps; } ip_dl; ipaddr_t ip_ipaddr; diff --git a/minix/net/inet/inet_config.c b/minix/net/inet/inet_config.c index 004074797..8bf9bf520 100644 --- a/minix/net/inet/inet_config.c +++ b/minix/net/inet/inet_config.c @@ -109,7 +109,7 @@ static void check_dev(int type, int ifno) char *defname; mode_t mode; u8_t minor_off; - } devlist[] = { + } devlist[5] = { { (char *) "/dev/eth", 0600, ETH_DEV_OFF }, { (char *) "/dev/psip", 0600, PSIP_DEV_OFF }, { (char *) "/dev/ip", 0600, IP_DEV_OFF }, @@ -423,7 +423,9 @@ void *alloc(size_t size) { /* Allocate memory on the heap with sbrk(). */ - return malloc(size); + void *addr = malloc(size); + memset(addr, 0, size); + return addr; } /* diff --git a/minix/servers/devman/main.c b/minix/servers/devman/main.c index 09e683adc..74a427cf5 100644 --- a/minix/servers/devman/main.c +++ b/minix/servers/devman/main.c @@ -70,8 +70,8 @@ read_hook int main (int argc, char* argv[]) { - struct fs_hooks hooks; - struct inode_stat root_stat; + static struct fs_hooks hooks; + static struct inode_stat root_stat; /* fill in the hooks */ memset(&hooks, 0, sizeof(hooks)); diff --git a/minix/servers/ds/store.h b/minix/servers/ds/store.h index 6868d38e3..e5fad1e93 100644 --- a/minix/servers/ds/store.h +++ b/minix/servers/ds/store.h @@ -18,9 +18,9 @@ struct data_store { char key[DS_MAX_KEYLEN]; /* key to lookup information */ char owner[DS_MAX_KEYLEN]; - union { + union dsi_u { unsigned u32; - struct { + struct dsi_mem { void *data; size_t length; size_t reallen; diff --git a/minix/servers/is/dmp_ds.c b/minix/servers/is/dmp_ds.c index 55da783ee..795c52317 100644 --- a/minix/servers/is/dmp_ds.c +++ b/minix/servers/is/dmp_ds.c @@ -3,7 +3,7 @@ #define LINES 22 -static struct data_store ds_store[NR_DS_KEYS]; +static struct data_store noxfer_ds_store[NR_DS_KEYS]; void data_store_dmp() { @@ -11,7 +11,7 @@ void data_store_dmp() static int prev_i = 0; int i, n = 0; - if (getsysinfo(DS_PROC_NR, SI_DATA_STORE, ds_store, sizeof(ds_store)) != OK) { + if (getsysinfo(DS_PROC_NR, SI_DATA_STORE, noxfer_ds_store, sizeof(noxfer_ds_store)) != OK) { printf("Error obtaining table from DS. Perhaps recompile IS?\n"); return; } @@ -19,7 +19,7 @@ void data_store_dmp() printf("Data store contents:\n"); printf("-slot- -----------key----------- -----owner----- ---type--- ----value---\n"); for(i = prev_i; i < NR_DS_KEYS && n < LINES; i++) { - p = &ds_store[i]; + p = &noxfer_ds_store[i]; if(!(p->flags & DSF_IN_USE)) continue; diff --git a/minix/servers/rs/type.h b/minix/servers/rs/type.h index 121ba7462..ea5a802d4 100644 --- a/minix/servers/rs/type.h +++ b/minix/servers/rs/type.h @@ -52,6 +52,7 @@ struct rupdate { }; /* Definition of an entry of the system process table. */ +typedef struct priv ixfer_priv_s; struct rproc { struct rprocpub *r_pub; /* pointer to the corresponding public entry */ struct rproc *r_old_rp; /* pointer to the slot with the old version */ @@ -83,7 +84,7 @@ struct rproc { char *r_exec; /* Executable image */ size_t r_exec_len; /* Length of image */ - struct priv r_priv; /* Privilege structure to be passed to the + ixfer_priv_s r_priv; /* Privilege structure to be passed to the * kernel. */ uid_t r_uid; diff --git a/minix/servers/vfs/fproc.h b/minix/servers/vfs/fproc.h index 51c0fffa2..d543be6f8 100644 --- a/minix/servers/vfs/fproc.h +++ b/minix/servers/vfs/fproc.h @@ -5,6 +5,7 @@ #include #include +#include /* This is the per-process information. A slot is reserved for each potential * process. Thus NR_PROCS must be the same as in the kernel. It is not diff --git a/minix/servers/vfs/select.c b/minix/servers/vfs/select.c index c042698ff..490fa3802 100644 --- a/minix/servers/vfs/select.c +++ b/minix/servers/vfs/select.c @@ -32,12 +32,14 @@ #define FROM_PROC 0 #define TO_PROC 1 +typedef fd_set *ixfer_fd_set_ptr; + static struct selectentry { struct fproc *requestor; /* slot is free iff this is NULL */ endpoint_t req_endpt; fd_set readfds, writefds, errorfds; fd_set ready_readfds, ready_writefds, ready_errorfds; - fd_set *vir_readfds, *vir_writefds, *vir_errorfds; + ixfer_fd_set_ptr vir_readfds, vir_writefds, vir_errorfds; struct filp *filps[OPEN_MAX]; int type[OPEN_MAX]; int nfds, nreadyfds; diff --git a/minix/servers/vm/pagetable.c b/minix/servers/vm/pagetable.c index 342774d37..e7885bc64 100644 --- a/minix/servers/vm/pagetable.c +++ b/minix/servers/vm/pagetable.c @@ -147,7 +147,7 @@ static u32_t findhole(int pages) /* Find a space in the virtual address space of VM. */ u32_t curv; int pde = 0, try_restart; - static u32_t lastv = 0; + static void *lastv = 0; pt_t *pt = &vmprocess->vm_pt; vir_bytes vmin, vmax; u32_t holev = NO_MEM; @@ -163,7 +163,7 @@ static u32_t findhole(int pages) assert((vmax % VM_PAGE_SIZE) == 0); assert(pages > 0); - curv = lastv; + curv = (u32_t) lastv; if(curv < vmin || curv >= vmax) curv = vmin; @@ -198,7 +198,7 @@ static u32_t findhole(int pages) /* if it's big enough, return it */ if(holesize == pages) { - lastv = curv + VM_PAGE_SIZE; + lastv = (void*) (curv + VM_PAGE_SIZE); return holev; } } diff --git a/minix/servers/vm/slaballoc.c b/minix/servers/vm/slaballoc.c index 6b19e61f5..a208548c1 100644 --- a/minix/servers/vm/slaballoc.c +++ b/minix/servers/vm/slaballoc.c @@ -116,11 +116,13 @@ struct sdh { #define JUNK 0xdeadbeef #define NOJUNK 0xc0ffee +struct slabdata { + u8_t data[DATABYTES]; + struct sdh sdh; +}; + static struct slabheader { - struct slabdata { - u8_t data[DATABYTES]; - struct sdh sdh; - } *list_head; + struct slabdata *list_head; } slabs[SLABSIZES]; static int objstats(void *, int, struct slabheader **, struct slabdata