lib/master.c
changeset 1258 900f1124e8f8
parent 1255 38b7e05b20c1
child 1259 5f9d1abbee71
--- a/lib/master.c	Fri Oct 10 07:58:48 2008 +0000
+++ b/lib/master.c	Fri Oct 10 08:34:15 2008 +0000
@@ -36,6 +36,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#include <sys/mman.h>
 
 #include "master.h"
 #include "domain.h"
@@ -64,6 +65,7 @@
 
     domain->index = (unsigned int) index;
     domain->master = master;
+    domain->process_data = NULL;
     return domain;
 }
 
@@ -106,12 +108,27 @@
 
 int ecrt_master_activate(ec_master_t *master)
 {
-    if (ioctl(master->fd, EC_IOCTL_ACTIVATE, NULL) == -1) {
+    if (ioctl(master->fd, EC_IOCTL_ACTIVATE,
+                &master->process_data_size) == -1) {
         fprintf(stderr, "Failed to activate master: %s\n",
                 strerror(errno));
         return -1; 
     }
 
+    if (master->process_data_size) {
+        master->process_data = mmap(0, master->process_data_size,
+                PROT_READ | PROT_WRITE, MAP_PRIVATE, master->fd, 0);
+        if (master->process_data == MAP_FAILED) {
+            fprintf(stderr, "Failed to map process data: %s", strerror(errno));
+            master->process_data = NULL;
+            master->process_data_size = 0;
+            return -1;
+        }
+
+        // Access the mapped region to cause the initial page fault
+        printf("pd: %x\n", master->process_data[0]);
+    }
+
     return 0;
 }