Commits

Anonymous committed 1889f31

More work on azpmem stuff

  • Participants
  • Parent commits 27c39a9

Comments (0)

Files changed (2)

File azm_mem_test/test.c

 
     // 1. Nice easy call, check is /dev/azul exists (I assume this 
     // would also check for the proxied variety of Azul MRI)
+    //
     int retcode = az_pmem_subsys_available();
-    assert(retcode, "The Azul subsytem was not available, no Kern module loaded ? check permissions on /dev/azul\n");
+    assertfalse(retcode, "The Azul subsytem was not available, no Kern module loaded ? check permissions on /dev/azul\n");
 
     // 2. We setup ‟funds” for the default ‟account”
     retcode = az_pmem_set_account_funds(avm_process_id, CHEAP_COMMITTED_MEMORY_ACCOUNT,
 
 }
 
-char* azmalloc(size_t bytes, char* preferred_addr, bool must_allocate_here, 
+char* azmalloc(size_t bytes, void* preferred_addr, bool must_allocate_here, 
         bool batchable, bool aliasable) {
 	address_t addr = (address_t) preferred_addr;
 	
 	assert((size_t)addr % getpagesize() == 0, "reserve_memory on page boundaries");
 	assert(bytes % getpagesize() == 0, "reserve_memory in page-sized chunks");
 	size_t reserved_size = round_to(bytes, BytesPerLargePage);
+	/*
 	assert(preferred_addr != NULL && must_allocate_here == true, 
             "need specific addresses for reservations with azmem");
+*/
 
 	int flags = batchable ? AZMM_BATCHABLE : 0;
 	flags |= aliasable ? AZMM_ALIASABLE : 0;
 
 	int ret = az_mreserve(addr, reserved_size, flags);
 	if (ret < 0) {
-		printf("osMME::reserve_memory failed: %s\n", strerror(errno));
+		printf("reserve_memory failed: %s\n", strerror(errno));
 		addr = NULL;
 	}
 	
     printf("First attempt to init some az mem\n");
     os_setup_avm_launch_env();
 
+    // py: len("This is a test") +_ 1 == 15
+    // It will throw a hissy fit unless it is asked to reseve
+    // in page size lumps, so lets do that
+
+    printf("Example args for cmd#1: 1 0x200000000 0x400000000\n");
+    char* wibble = azmalloc(0x400000000, (void*) 0x200000000, false, false, false);   
+    assert(wibble != NULL, "Gack memory not reserved\n");
+
+    // Yeah its crummy, its an example alright !!
+    wibble[0] = 'T';
+    wibble[1] = 'h';
+    wibble[2] = 'i';
+    wibble[3] = 's';
+    wibble[4] = ' ';
+    wibble[5] = 'i';
+    wibble[6] = 's';
+    wibble[7] = ' ';
+    wibble[8] = 'a';
+    wibble[9] = ' ';
+    wibble[10] = 't';
+    wibble[11] = 'e';
+    wibble[12] = 's';
+    wibble[13] = 't';
+    wibble[14] = '\0';
+
+    // I hope that azul memory can be used somewhat like a real
+    // void* malloc c pointer you would get from good old fashioned
+    // malloc/calloc libc and friends
+    // else this is going to break rather badly
+    printf("Did the azul test return \"This is a test\" ? -> [%s]\n", 
+            wibble);
+
+    // Ok so I cant yet free memory, so lets just screw the OS and leak
+    // I think my random compile of the kernel side does not free memory
+    // quite right anyhow
+    //azfree(wibble);
+
     return 0;
 }
 /* vim: set et fenc=utf-8 ff=unix sts=4 sw=4 ts=4 foldmethod=marker foldlevel=0: */

File azm_mem_test/utils.h

 }
 
 inline intptr_t round_to(intptr_t x, uintx s) {
-    assert(!is_power_of_2(s), "s must be a power of 2");
+    printf("Size of s : %d\n", s);
+    //assert(!is_power_of_2(s), "s must be a power of 2");
     const uintx m = s - 1;
     return mask_bits(x + m, ~m);
 }