34 |
|
#endif |
35 |
|
|
36 |
|
// Variables for Video on SEGV support |
37 |
< |
static uint8 *the_host_buffer; // Host frame buffer in VOSF mode |
38 |
< |
static uint32 the_buffer_size; // Size of allocated the_buffer |
37 |
> |
static uint8 *the_host_buffer; // Host frame buffer in VOSF mode |
38 |
> |
static uint32 the_buffer_size; // Size of allocated the_buffer |
39 |
|
|
40 |
|
struct ScreenPageInfo { |
41 |
|
int top, bottom; // Mapping between this virtual page and Mac scanlines |
131 |
|
#endif |
132 |
|
} |
133 |
|
|
134 |
– |
static int zero_fd = -1; |
135 |
– |
|
134 |
|
#ifdef HAVE_PTHREADS |
135 |
|
static pthread_mutex_t vosf_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect frame buffer (dirtyPages in fact) |
136 |
|
#define LOCK_VOSF pthread_mutex_lock(&vosf_lock); |
151 |
|
return l; |
152 |
|
} |
153 |
|
|
154 |
+ |
// Extend size to page boundary |
155 |
+ |
static uint32 page_extend(uint32 size) |
156 |
+ |
{ |
157 |
+ |
const uint32 page_size = getpagesize(); |
158 |
+ |
const uint32 page_mask = page_size - 1; |
159 |
+ |
return (size + page_mask) & ~page_mask; |
160 |
+ |
} |
161 |
+ |
|
162 |
|
|
163 |
|
/* |
164 |
|
* Initialize mainBuffer structure |
171 |
|
const uint32 page_mask = page_size - 1; |
172 |
|
|
173 |
|
mainBuffer.memBase = (uintptr) the_buffer; |
174 |
< |
// Align the frame buffer on page boundary |
174 |
> |
// Round up frame buffer base to page boundary |
175 |
|
mainBuffer.memStart = (uintptr)((((unsigned long) the_buffer) + page_mask) & ~page_mask); |
176 |
|
mainBuffer.memLength = the_buffer_size; |
177 |
|
mainBuffer.memEnd = mainBuffer.memStart + mainBuffer.memLength; |
201 |
|
|
202 |
|
PFLAG_CLEAR_ALL; |
203 |
|
// Safety net to insure the loops in the update routines will terminate |
204 |
< |
// See a discussion in <video_vosf.h> for further details |
204 |
> |
// See "How can we deal with array overrun conditions ?" hereunder for further details |
205 |
|
PFLAG_CLEAR(mainBuffer.pageCount); |
206 |
|
PFLAG_SET(mainBuffer.pageCount+1); |
207 |
|
|
232 |
|
|
233 |
|
|
234 |
|
/* |
235 |
< |
* Page-aligned memory allocation |
235 |
> |
* Screen fault handler |
236 |
|
*/ |
237 |
|
|
232 |
– |
// Extend size to page boundary |
233 |
– |
static uint32 page_extend(uint32 size) |
234 |
– |
{ |
235 |
– |
const uint32 page_size = getpagesize(); |
236 |
– |
const uint32 page_mask = page_size - 1; |
237 |
– |
return (size + page_mask) & ~page_mask; |
238 |
– |
} |
239 |
– |
|
240 |
– |
// Screen fault handler |
238 |
|
static bool screen_fault_handler(sigsegv_address_t fault_address, sigsegv_address_t fault_instruction) |
239 |
|
{ |
240 |
|
D(bug("screen_fault_handler: ADDR=0x%08X from IP=0x%08X\n", fault_address, fault_instruction)); |
241 |
|
const uintptr addr = (uintptr)fault_address; |
242 |
|
|
243 |
|
/* Someone attempted to write to the frame buffer. Make it writeable |
244 |
< |
* now so that the data could actually be written. It will be made |
244 |
> |
* now so that the data could actually be written to. It will be made |
245 |
|
* read-only back in one of the screen update_*() functions. |
246 |
|
*/ |
247 |
|
if ((addr >= mainBuffer.memStart) && (addr < mainBuffer.memEnd)) { |
273 |
|
return false; |
274 |
|
} |
275 |
|
|
276 |
+ |
|
277 |
|
/* |
278 |
|
* Update display for Windowed mode and VOSF |
279 |
|
*/ |
362 |
|
else |
363 |
|
XPutImage(x_display, the_win, the_gc, img, 0, y1, 0, y1, VideoMonitor.mode.x, height); |
364 |
|
} |
367 |
– |
|
365 |
|
mainBuffer.dirty = false; |
366 |
|
} |
367 |
|
|
368 |
|
|
369 |
|
/* |
370 |
|
* Update display for DGA mode and VOSF |
371 |
< |
* (only in Direct Addressing mode) |
371 |
> |
* (only in Real or Direct Addressing mode) |
372 |
|
*/ |
373 |
|
|
374 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |