+void Multiboot_FreeModules(const int ModuleCount, tBootModule *Modules)
+{
+ for( int i = 0; i < ModuleCount; i ++ )
+ {
+ Uint ofs = Modules[i].PBase % PAGE_SIZE;
+ Uint nPages = (Modules[i].Size+ofs+PAGE_SIZE-1) / PAGE_SIZE;
+ MM_UnmapHWPages(Modules[i].Base, nPages);
+ MM_UnmapHWPages(Modules[i].ArgString, 2);
+
+ // TODO: handle previous freeing of this page
+ for( int pg = 0; pg < nPages; pg ++ )
+ MM_DerefPhys( Modules[i].PBase + pg*PAGE_SIZE );
+ }
+ free(Modules);
+}
+