[gandr]: implement /_PDCLIB_(alloc|free)pages/
authorOwen Shepherd <owen.shepherd@e43.eu>
Sun, 23 Nov 2014 18:30:13 +0000 (18:30 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Sun, 23 Nov 2014 18:30:13 +0000 (18:30 +0000)
platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c
platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c

index bdcd525ca3ece71ab92d2e63829c357113eb58b2..485177914b3709ff0e07939b5581f953223e4c64 100644 (file)
@@ -6,18 +6,23 @@
    Permission is granted to use, modify, and / or redistribute at will.
 */
 
-/* This is a stub implementation of _PDCLIB_allocpages
-*/
-
 #include <stdint.h>
 #include <stddef.h>
 #include <_PDCLIB_glue.h>
 #include <errno.h>
+#include <gd_bal.h>
 
 void * _PDCLIB_allocpages( size_t n )
 {
-    errno = ENOTSUP;
-    return NULL;
+    void *p = NULL;
+    int rv = gd_alloc_pages( gd_loader_data, &p, n );
+
+    if (rv) {
+        errno = rv;
+        return NULL;
+    } else {
+        return p;
+    }
 }
 
 #ifdef TEST
index c77687652e64de0739b74998a9f5a954fbd247e9..285589f6003596b8c362be35e5d442c7852f72fb 100644 (file)
 #include <stddef.h>\r
 #include <_PDCLIB_glue.h>\r
 #include <errno.h>\r
+#include <gd_bal.h>\r
 \r
 void _PDCLIB_freepages( void * p, size_t n )\r
 {\r
-    return;\r
+    int rv = 0;\r
+    if((rv = gd_free_pages( p, n ))) {\r
+        perror("_PDCLIB_freepages");\r
+        abort();\r
+    }\r
 }\r
 \r
 #ifdef TEST\r