Memory.inc

This file defines constants, structures, and macros for memory management functions of PwnOS.

See Also

Authors

  • Neil G.  Dickson
Summary
Memory.incThis file defines constants, structures, and macros for memory management functions of PwnOS.
PHYSPAGEINFOThis structure is an entry in the Physical To Virtual Table.
Constants
Memory Map ConstantsThese define the sizes and addresses of fixed-location data and data blocks.

PHYSPAGEINFO

This structure is an entry in the Physical To Virtual Table.

256 of these entries make up each of the 256 sections of the table.  A physical page can’t have more than one virtual address so if needed, make a copy of the page.  This was decided for simplicity and since the OS is focused toward having only a few processes running at once anyway.

GetVirtAddr and RegisterNewPhysPg rely heavily on this structure.

Members

pVirtualvirtual address of this physical page in the memory space of process(es) determined by hProcess; PHYSPAGEINFO_FREE if this page isn’t used; PHYSPAGEINFO_UNUSABLE if this page is never allowed to be used (e.g. video memory bank at 0A0000h)
hProcesshandle of the process owning this; can also be a handle to a handle list (though not implemented yet)
Ageage of the page in a format indicating how long ago the past 4 accesses were (1 byte each); 00 = accessed in current round; 01-FE = accessed 01-FE cycles before current round or more recent access; FF = accessed an indeterminably long time before current round or more recent access.
Reservedreserved for future use, and padding to 16 bytes
Summary
Constants
Memory Map ConstantsThese define the sizes and addresses of fixed-location data and data blocks.

Constants

Memory Map Constants

These define the sizes and addresses of fixed-location data and data blocks.

Members

PA_GDTPhysical Address of GDT; Write code w\ conditional assembly optimized for 0 when it is equal to 0
VA_GDTVirtual Address of GDT
SZ_GDTSize of GDT; first few plus 1 TSS descriptor for each processor
This file defines page-level memory management functions of PwnOS.
This procedure gets the virtual address of a physical address (whatever process it’s for).
This procedure finds a free physical page and maps a virtual address to it for a specific process.
GDT dq 0 ;NULL descriptor
INITIAL GLOBAL DESCRIPTOR TABLE