|
Revision 1668, 1.6 KB
(checked in by mwhitworth, 3 years ago)
|
|
Merge in changes from keobject.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #ifndef PG_ALLOC_H |
|---|
| 20 | #define PG_ALLOC_H |
|---|
| 21 | |
|---|
| 22 | #include <llist.h> |
|---|
| 23 | #include <typedefs.h> |
|---|
| 24 | #include <wait.h> |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | struct PhysPage |
|---|
| 28 | { |
|---|
| 29 | DWORD physAddr; |
|---|
| 30 | int refs; |
|---|
| 31 | struct ListHead list; |
|---|
| 32 | }; |
|---|
| 33 | |
|---|
| 34 | int PageEarlyInit(DWORD endPfn); |
|---|
| 35 | int PageInit(); |
|---|
| 36 | struct PhysPage* PageGetStruct(DWORD physAddr); |
|---|
| 37 | struct PhysPage* PageAlloc(); |
|---|
| 38 | struct PhysPage* PageAllocLow(); |
|---|
| 39 | void PageFree(struct PhysPage* page); |
|---|
| 40 | |
|---|
| 41 | static inline void PageFreeAddr(DWORD physAddr) |
|---|
| 42 | { |
|---|
| 43 | struct PhysPage* page = PageGetStruct(physAddr); |
|---|
| 44 | |
|---|
| 45 | if (page) |
|---|
| 46 | PageFree(page); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | void PageReserveArea(DWORD start,DWORD size); |
|---|
| 50 | WaitQueue* PageGetWaitQueue(struct PhysPage* page); |
|---|
| 51 | |
|---|
| 52 | #define PageGet(page) ((page)->refs++) |
|---|
| 53 | #define PagePut(page) do { \ |
|---|
| 54 | (page)->refs--; if ((page)->refs <= 0) PageFree((page)); } while (0) |
|---|
| 55 | #define CopyPage(dest,src) memcpy((dest),(src),PAGE_SIZE) |
|---|
| 56 | |
|---|
| 57 | #endif |
|---|