case V3_RESET_MEMORY: {
DEBUG("Resetting memory\n");
if (palacios_deinit_mm() == -1) {
- ERROR("Error resetting Palacios memory\n");
+ ERROR("Error deiniting the Palacios memory manager\n");
return -EFAULT;
}
+ if (palacios_init_mm()) {
+ ERROR("Error initing the Palacios memory manager\n");
+ return -EFAULT;
+ }
break;
}
# Executables that implement core functionality
#
BASE_EXECS = v3_mem \
- v3_mem_free \
+ v3_mem_reset \
v3_create \
v3_create_bind \
v3_free \
else \
echo "In order to use v3_vncclient/server you must have" ; \
echo "previously built or received palacios/linux_usr/x0vncserver" ; \
- echo "To learn more about this, look in palacios/linux_usr/vnc"; \
+ echo "To learn more about this, look in palacios/linux_usr/vnc"; \
fi;
#
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-
-#include "v3_ctrl.h"
-
-int main(void)
-{
- FILE * fp;
- char * filepath = "/proc/v3vee/v3-mem";
- char line[255];
- unsigned long base_addr = 0;
- unsigned long long num_pages = 0;
- unsigned long amount_allocated = 0;
- unsigned long long block_size = 0;
- int i = 0;
- int v3_fd;
-
- fp = fopen(filepath, "r");
- if(fp == NULL) {
- fprintf(stderr, "Could not open %s\n", filepath);
- return -1;
- }
- memset(line, 0, 255);
- fgets(line, 255, fp);
- base_addr = strtoul(line, NULL, 16);
- base_addr = base_addr / (1024*1024);
- memset(line, 0, 255);
- fgets(line, 255, fp);
- num_pages = strtoull(line, NULL, 10);
- amount_allocated = (num_pages*4096)/(1024*1024);
-
- fclose(fp);
-
- /* now get the block size */
- fp = fopen("/sys/devices/system/memory/block_size_bytes", "r");
- if(fp == NULL) {
- fprintf(stderr, "Cannot lookup bytes per block size\n");
- return -1;
- }
- memset(line, 0, 255);
- fgets(line, 255, fp);
- block_size = strtoull(line, NULL, 16);
- block_size = block_size / (1024*1024); //convert to MB
- fclose(fp);
-
- /* turn base_addr into the region number */
- base_addr = base_addr / block_size;
-
- for(i=0;i< (amount_allocated / block_size); i++) {
- char path[50];
-
- memset(path, 0, 50);
- sprintf(path,"/sys/devices/system/memory/memory%d/state",
- base_addr);
- fp = fopen(path, "w+");
- if(fp == NULL) {
- fprintf(stderr, "Could not open %s\n", path);
- return -1;
- }
- printf("Sending \"online\" to memory%d\n", base_addr);
- fprintf(fp, "online");
- fclose(fp);
- base_addr++;
- }
-
- v3_fd = open(v3_dev, O_RDONLY);
- if (v3_fd == -1) {
- printf("Error opening V3Vee control device\n");
- return -1;
- }
-
- ioctl(v3_fd, V3_RESET_MEMORY, NULL);
- close(v3_fd);
-
- return 0;
-}
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include "v3_ctrl.h"
+
+int main(int argc, char *argv[])
+{
+ int v3_fd;
+
+ if (argc!=2 || strcmp(argv[1],"-f")) {
+ printf("usage: v3_mem_reset -f\n\n"
+ "This will deinit and then init the memory manager.\n\nYou probably do not want to do this.\n");
+ return -1;
+ }
+
+
+ v3_fd = open("/dev/v3vee", O_RDONLY);
+ if (v3_fd == -1) {
+ printf("Error opening V3Vee control device\n");
+ return -1;
+ }
+
+ ioctl(v3_fd, V3_RESET_MEMORY, NULL);
+ close(v3_fd);
+
+ return 0;
+}