mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
[metal] Clean up code for getting pointer to struct mman
(#828)
Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
This commit is contained in:
parent
5a6a4819d4
commit
e47c0cc929
5 changed files with 8 additions and 6 deletions
|
@ -23,9 +23,8 @@
|
|||
noasan int sys_munmap_metal(void *addr, size_t size) {
|
||||
size_t i;
|
||||
uint64_t *e, paddr;
|
||||
struct mman *mm;
|
||||
struct mman *mm = __get_mm();
|
||||
uint64_t *pml4t = __get_pml4t();
|
||||
mm = (struct mman *)(BANE + 0x0500);
|
||||
for (i = 0; i < size; i += 4096) {
|
||||
e = __get_virtual(mm, pml4t, (uint64_t)addr + i, false);
|
||||
if (e) {
|
||||
|
|
|
@ -46,7 +46,7 @@ noasan struct DirectMap sys_mmap_metal(void *vaddr, size_t size, int prot,
|
|||
struct mman *mm;
|
||||
struct DirectMap res;
|
||||
uint64_t addr, faddr = 0, page, e, *pte, *fdpte, *pml4t;
|
||||
mm = (struct mman *)(BANE + 0x0500);
|
||||
mm = __get_mm();
|
||||
pml4t = __get_pml4t();
|
||||
size = ROUNDUP(size, 4096);
|
||||
addr = (uint64_t)vaddr;
|
||||
|
|
|
@ -176,7 +176,7 @@ __msabi noasan EFI_STATUS EfiMain(EFI_HANDLE ImageHandle,
|
|||
SystemTable->BootServices->AllocatePages(
|
||||
AllocateAddress, EfiRuntimeServicesData,
|
||||
((_end - __executable_start) + 4095) / 4096, &Address);
|
||||
mm = (struct mman *)0x0500;
|
||||
mm = __get_mm_phy();
|
||||
SystemTable->BootServices->SetMem(mm, sizeof(*mm), 0);
|
||||
SystemTable->BootServices->SetMem(
|
||||
(void *)0x79000, 0x7e000 - 0x79000 + sizeof(struct EfiArgs), 0);
|
||||
|
|
|
@ -225,5 +225,8 @@ forceinline void outb(unsigned short port, unsigned char byte) {
|
|||
(uint64_t *)(BANE + cr3); \
|
||||
})
|
||||
|
||||
#define __get_mm() ((struct mman *)(BANE + 0x0500))
|
||||
#define __get_mm_phy() ((struct mman *)0x0500)
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_RUNTIME_PC_H_ */
|
||||
|
|
|
@ -35,7 +35,7 @@ struct Tty _vga_tty;
|
|||
|
||||
void _vga_reinit(struct Tty *tty, unsigned short starty, unsigned short startx,
|
||||
unsigned init_flags) {
|
||||
struct mman *mm = (struct mman *)(BANE + 0x0500);
|
||||
struct mman *mm = __get_mm();
|
||||
unsigned char vid_type = mm->pc_video_type;
|
||||
unsigned short height = mm->pc_video_height, width = mm->pc_video_width,
|
||||
stride = mm->pc_video_stride;
|
||||
|
@ -66,7 +66,7 @@ void _vga_reinit(struct Tty *tty, unsigned short starty, unsigned short startx,
|
|||
|
||||
textstartup void _vga_init(void) {
|
||||
if (IsMetal()) {
|
||||
struct mman *mm = (struct mman *)(BANE + 0x0500);
|
||||
struct mman *mm = __get_mm();
|
||||
unsigned short starty = mm->pc_video_curs_info.y,
|
||||
startx = mm->pc_video_curs_info.x;
|
||||
_vga_reinit(&_vga_tty, starty, startx, 0);
|
||||
|
|
Loading…
Reference in a new issue