mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-03 16:33:47 +00:00
reserve framebuffer
This commit is contained in:
parent
d906fb23b0
commit
1f2b35fef2
@ -222,6 +222,13 @@ void vm_exit(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *reserved_buf;
|
||||
static const size_t RESERVED_SIZE = 64 * 1024 * 1024; // for 5K Retina
|
||||
|
||||
void *vm_acquire_reserved(size_t size) {
|
||||
return reserved_buf && size <= RESERVED_SIZE ? reserved_buf : VM_MAP_FAILED;
|
||||
}
|
||||
|
||||
/* Allocate zero-filled memory of SIZE bytes. The mapping is private
|
||||
and default protection bits are read / write. The return value
|
||||
is the actual mapping address chosen or VM_MAP_FAILED for errors. */
|
||||
@ -243,11 +250,13 @@ void * vm_acquire(size_t size, int options)
|
||||
|
||||
#if defined(HAVE_MACH_VM)
|
||||
// vm_allocate() returns a zero-filled memory region
|
||||
kern_return_t ret_code = vm_allocate(mach_task_self(), (vm_address_t *)&addr, size, TRUE);
|
||||
kern_return_t ret_code = vm_allocate(mach_task_self(), (vm_address_t *)&addr, reserved_buf ? size : size + RESERVED_SIZE, TRUE);
|
||||
if (ret_code != KERN_SUCCESS) {
|
||||
errno = vm_error(ret_code);
|
||||
return VM_MAP_FAILED;
|
||||
}
|
||||
if (!reserved_buf)
|
||||
reserved_buf = (char *)addr + size;
|
||||
#elif defined(HAVE_MMAP_VM)
|
||||
int fd = zero_fd;
|
||||
int the_map_flags = translate_map_flags(options) | map_flags;
|
||||
|
@ -99,6 +99,8 @@ extern void vm_exit(void);
|
||||
|
||||
extern void * vm_acquire(size_t size, int options = VM_MAP_DEFAULT);
|
||||
|
||||
extern void * vm_acquire_reserved(size_t size);
|
||||
|
||||
/* Allocate zero-filled memory at exactly ADDR (which must be page-aligned).
|
||||
Returns 0 if successful, -1 on errors. */
|
||||
|
||||
|
@ -215,6 +215,9 @@ extern void SysMountFirstFloppy(void);
|
||||
|
||||
static void *vm_acquire_framebuffer(uint32 size)
|
||||
{
|
||||
#ifdef HAVE_MACH_VM
|
||||
return vm_acquire_reserved(size);
|
||||
#else
|
||||
// always try to reallocate framebuffer at the same address
|
||||
static void *fb = VM_MAP_FAILED;
|
||||
if (fb != VM_MAP_FAILED) {
|
||||
@ -228,11 +231,12 @@ static void *vm_acquire_framebuffer(uint32 size)
|
||||
if (fb == VM_MAP_FAILED)
|
||||
fb = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_32BIT);
|
||||
return fb;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void vm_release_framebuffer(void *fb, uint32 size)
|
||||
{
|
||||
vm_release(fb, size);
|
||||
// vm_release(fb, size);
|
||||
}
|
||||
|
||||
static inline int get_customized_color_depth(int default_depth)
|
||||
|
Loading…
Reference in New Issue
Block a user