mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
[metal] Fix video mode filtering & frame buffer ref-counting (#889)
Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
This commit is contained in:
parent
0d748ad58e
commit
b21842ed7a
3 changed files with 20 additions and 10 deletions
|
@ -159,6 +159,7 @@
|
|||
#define PAGE_V /* */ 0b000000000001
|
||||
#define PAGE_RW /* */ 0b000000000010
|
||||
#define PAGE_U /* */ 0b000000000100
|
||||
#define PAGE_PCD /* */ 0b000000010000
|
||||
#define PAGE_PS /* */ 0b000010000000
|
||||
#define PAGE_G /* */ 0b000100000000
|
||||
#define PAGE_IGN1 /* */ 0b111000000000
|
||||
|
@ -196,6 +197,20 @@ void __ref_page(struct mman *, uint64_t *, uint64_t);
|
|||
void __ref_pages(struct mman *, uint64_t *, uint64_t, uint64_t);
|
||||
void __unref_page(struct mman *, uint64_t *, uint64_t);
|
||||
|
||||
/**
|
||||
* Identity maps an area of physical memory to its negative address and
|
||||
* marks it as permanently referenced and unreclaimable (so that it will
|
||||
* never be added to the free list). This is useful for special-purpose
|
||||
* physical memory regions, such as video frame buffers and memory-mapped
|
||||
* I/O devices.
|
||||
*/
|
||||
forceinline void __invert_and_perm_ref_memory_area(struct mman *mm,
|
||||
uint64_t *pml4t, uint64_t ps,
|
||||
uint64_t size,
|
||||
uint64_t pte_flags) {
|
||||
__invert_memory_area(mm, pml4t, ps, size, pte_flags | PAGE_REFC);
|
||||
}
|
||||
|
||||
forceinline unsigned char inb(unsigned short port) {
|
||||
unsigned char al;
|
||||
asm volatile("inb\t%1,%0" : "=a"(al) : "dN"(port));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue