Add READ_ONCE and WRITE_ONCE (XCC)
[akaros.git] / kern / include / ros / procinfo.h
index 306a2a5..56bf7d9 100644 (file)
@@ -1,13 +1,13 @@
 /* See COPYRIGHT for copyright information. */
 
-#ifndef ROS_PROCINFO_H
-#define ROS_PROCINFO_H
+#pragma once
 
 #include <ros/memlayout.h>
 #include <ros/common.h>
 #include <ros/resource.h>
 #include <ros/atomic.h>
 #include <ros/arch/arch.h>
+#include <ros/cpu_feat.h>
 #include <string.h>
 
 /* Process creation flags */
@@ -52,22 +52,39 @@ typedef struct procinfo {
        size_t max_vcores;      /* TODO: change to a uint32_t */
        uint64_t tsc_freq;
        uint64_t timing_overhead;
-       void *heap_bottom;
+       uintptr_t program_end;
        /* glibc relies on stuff above this point.  if you change it, you need to
         * rebuild glibc. */
        bool is_mcp;                    /* is in multi mode */
        unsigned long           res_grant[MAX_NUM_RESOURCES];
-       struct vcore            vcoremap[MAX_NUM_CPUS];
+       struct vcore            vcoremap[MAX_NUM_CORES];
        uint32_t                        num_vcores;
-       struct pcore            pcoremap[MAX_NUM_CPUS];
+       struct pcore            pcoremap[MAX_NUM_CORES];
        seq_ctr_t                       coremap_seqctr;
 } procinfo_t;
-#define PROCINFO_NUM_PAGES  ((sizeof(procinfo_t)-1)/PGSIZE + 1)        
+#define PROCINFO_NUM_PAGES  ((sizeof(procinfo_t)-1)/PGSIZE + 1)
 
+/* We align this so that the kernel can easily allocate it in the BSS */
+struct proc_global_info {
+       unsigned long cpu_feats[__NR_CPU_FEAT_BITS];
+       uint64_t x86_default_xcr0;
+       uint64_t tsc_freq;
+       uint64_t tsc_overhead;
+       uint64_t bus_freq;
+       uint64_t walltime_ns_last;
+       uint64_t tsc_cycles_last;
+} __attribute__((aligned(PGSIZE)));
+#define PROCGINFO_NUM_PAGES  (sizeof(struct proc_global_info) / PGSIZE)
+
+#ifdef ROS_KERNEL
+
+/* defined in init.c */
+extern struct proc_global_info __proc_global_info;
 
-// this is how user programs access the procinfo page
-#ifndef ROS_KERNEL
-# define __procinfo (*(procinfo_t*)UINFO)
+#else /* Userland */
+
+#define __procinfo (*(procinfo_t*)UINFO)
+#define __proc_global_info (*(struct proc_global_info*)UGINFO)
 
 #include <ros/common.h>
 #include <ros/atomic.h>
@@ -82,6 +99,9 @@ static inline uint32_t __get_vcoreid_from_procinfo(void)
         * there is a 'memory barrier' between the IPI write and the seqctr write.
         * I think this is true. */
        uint32_t kpcoreid, kvcoreid;
+       extern long __ros_syscall_noerrno(unsigned int _num, long _a0, long _a1,
+                                         long _a2, long _a3, long _a4, long _a5);
+
        seq_ctr_t old_seq;
        do {
                cmb();
@@ -101,5 +121,3 @@ static inline uint32_t __get_vcoreid(void)
 }
 
 #endif /* ifndef ROS_KERNEL */
-
-#endif // !ROS_PROCDATA_H