56 |
|
# include <fcntl.h> |
57 |
|
# include <sys/mman.h> |
58 |
|
# include "sigsegv.h" |
59 |
+ |
# include "vm_alloc.h" |
60 |
|
#endif |
61 |
|
|
62 |
|
#include "cpu_emulation.h" |
188 |
|
}; |
189 |
|
|
190 |
|
struct ScreenInfo { |
191 |
< |
uint32 memBase; // Real start address |
192 |
< |
uint32 memStart; // Start address aligned to page boundary |
193 |
< |
uint32 memEnd; // Address of one-past-the-end of the screen |
191 |
> |
uintptr memBase; // Real start address |
192 |
> |
uintptr memStart; // Start address aligned to page boundary |
193 |
> |
uintptr memEnd; // Address of one-past-the-end of the screen |
194 |
|
uint32 memLength; // Length of the memory addressed by the screen pages |
195 |
|
|
196 |
|
uint32 pageSize; // Size of a page |
545 |
|
} |
546 |
|
|
547 |
|
#ifdef ENABLE_VOSF |
548 |
< |
// Allocate a page-aligned chunk of memory for frame buffer |
548 |
< |
the_buffer_size = align_on_page_boundary((aligned_height + 2) * img->bytes_per_line); |
548 |
> |
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
549 |
|
the_host_buffer = the_buffer_copy; |
550 |
< |
|
551 |
< |
the_buffer_copy = (uint8 *)allocate_framebuffer(the_buffer_size); |
552 |
< |
memset(the_buffer_copy, 0, the_buffer_size); |
553 |
< |
|
554 |
< |
the_buffer = (uint8 *)allocate_framebuffer(the_buffer_size); |
555 |
< |
memset(the_buffer, 0, the_buffer_size); |
550 |
> |
the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line); |
551 |
> |
the_buffer_copy = (uint8 *)vm_acquire(the_buffer_size); |
552 |
> |
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
553 |
|
#else |
554 |
|
// Allocate memory for frame buffer |
555 |
|
the_buffer = (uint8 *)malloc((aligned_height + 2) * img->bytes_per_line); |
718 |
|
use_vosf = Screen_blitter_init(&visualInfo, true); |
719 |
|
|
720 |
|
if (use_vosf) { |
721 |
< |
the_host_buffer = the_buffer; |
722 |
< |
the_buffer_size = align_on_page_boundary((height + 2) * bytes_per_row); |
723 |
< |
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
724 |
< |
memset(the_buffer_copy, 0, the_buffer_size); |
725 |
< |
the_buffer = (uint8 *)allocate_framebuffer(the_buffer_size); |
729 |
< |
memset(the_buffer, 0, the_buffer_size); |
721 |
> |
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
722 |
> |
the_host_buffer = the_buffer; |
723 |
> |
the_buffer_size = page_extend((height + 2) * bytes_per_row); |
724 |
> |
the_buffer_copy = (uint8 *)vm_acquire(the_buffer_size); |
725 |
> |
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
726 |
|
} |
727 |
|
#else |
728 |
|
use_vosf = false; |
817 |
|
bytes_per_row *= 4; |
818 |
|
break; |
819 |
|
} |
820 |
< |
|
820 |
> |
|
821 |
> |
#ifdef VIDEO_VOSF |
822 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
823 |
|
// Screen_blitter_init() returns TRUE if VOSF is mandatory |
824 |
|
// i.e. the framebuffer update function is not Blit_Copy_Raw |
825 |
|
use_vosf = Screen_blitter_init(&visualInfo, true); |
826 |
|
|
827 |
|
if (use_vosf) { |
828 |
< |
the_host_buffer = the_buffer; |
829 |
< |
the_buffer_size = align_on_page_boundary((height + 2) * bytes_per_row); |
830 |
< |
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
831 |
< |
memset(the_buffer_copy, 0, the_buffer_size); |
832 |
< |
the_buffer = (uint8 *)allocate_framebuffer(the_buffer_size); |
836 |
< |
memset(the_buffer, 0, the_buffer_size); |
828 |
> |
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
829 |
> |
the_host_buffer = the_buffer; |
830 |
> |
the_buffer_size = page_extend((height + 2) * bytes_per_row); |
831 |
> |
the_buffer_copy = (uint8 *)vm_acquire(the_buffer_size); |
832 |
> |
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
833 |
|
} |
834 |
< |
#elif defined(ENABLE_VOSF) |
839 |
< |
// The UAE memory handlers will already handle color conversion, if needed. |
834 |
> |
#else |
835 |
|
use_vosf = false; |
836 |
|
#endif |
837 |
+ |
#endif |
838 |
|
|
839 |
|
set_video_monitor(width, height, bytes_per_row, true); |
840 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
922 |
|
const uint32 page_size = getpagesize(); |
923 |
|
const uint32 page_mask = page_size - 1; |
924 |
|
|
925 |
< |
mainBuffer.memBase = (uint32) the_buffer; |
925 |
> |
mainBuffer.memBase = (uintptr) the_buffer; |
926 |
|
// Align the frame buffer on page boundary |
927 |
< |
mainBuffer.memStart = (uint32)((((unsigned long) the_buffer) + page_mask) & ~page_mask); |
927 |
> |
mainBuffer.memStart = (uintptr)((((unsigned long) the_buffer) + page_mask) & ~page_mask); |
928 |
|
mainBuffer.memLength = the_buffer_size; |
929 |
|
mainBuffer.memEnd = mainBuffer.memStart + mainBuffer.memLength; |
930 |
|
|
972 |
|
} |
973 |
|
|
974 |
|
// We can now write-protect the frame buffer |
975 |
< |
if (mprotect((caddr_t)mainBuffer.memStart, mainBuffer.memLength, PROT_READ) != 0) |
975 |
> |
if (vm_protect((char *)mainBuffer.memStart, mainBuffer.memLength, VM_PAGE_READ) != 0) |
976 |
|
return false; |
977 |
|
} |
978 |
|
#endif |
1256 |
|
} |
1257 |
|
#ifdef ENABLE_VOSF |
1258 |
|
else { |
1259 |
< |
if (the_buffer != (uint8 *)MAP_FAILED) { |
1260 |
< |
munmap((caddr_t)the_buffer, the_buffer_size); |
1259 |
> |
if (the_buffer != (uint8 *)VM_MAP_FAILED) { |
1260 |
> |
vm_release(the_buffer, the_buffer_size); |
1261 |
|
the_buffer = 0; |
1262 |
|
} |
1263 |
|
|
1264 |
< |
if (the_buffer_copy != (uint8 *)MAP_FAILED) { |
1265 |
< |
munmap((caddr_t)the_buffer_copy, the_buffer_size); |
1264 |
> |
if (the_buffer_copy != (uint8 *)VM_MAP_FAILED) { |
1265 |
> |
vm_release(the_buffer_copy, the_buffer_size); |
1266 |
|
the_buffer_copy = 0; |
1267 |
|
} |
1268 |
|
} |