/*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the
+ * License may not be used to create, or enable the creation or
+ * redistribution of, unlawful or unlicensed copies of an Apple operating
+ * system, or to circumvent, violate, or enable the circumvention or
+ * violation of, any terms of an Apple operating system software license
+ * agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
* file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
* limitations under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
*/
/*
* @OSF_FREE_COPYRIGHT@
#include <vc.h>
#include <console/video_console.h>
+
+#include <kern/kern_types.h>
+#include <kern/kalloc.h>
#include <kern/debug.h>
#include <kern/lock.h>
#include <kern/spl.h>
-#include <kern/time_out.h>
+#include <kern/thread_call.h>
+
+#include <vm/pmap.h>
#include <vm/vm_kern.h>
+#include <machine/io_map_entries.h>
+
#include <pexpert/pexpert.h>
#include "iso_font.c"
static char gc_tab_stops[255];
static int gc_scrreg_top, gc_scrreg_bottom;
+enum { kProgressAcquireDelay = 5 /* secs */ };
+
enum vt100state_e {
ESnormal, /* Nothing yet */
ESesc, /* Got ESC */
{
spl_t s;
+ if (!gc_buffer_size) return;
+
s = splhigh();
simple_lock(&gc_buffer_lock);
simple_unlock( &gc_buffer_lock );
splx( s );
- kfree( (vm_offset_t)buffer_attributes, buffer_size );
- kfree( (vm_offset_t)buffer_characters, buffer_size );
- kfree( (vm_offset_t)buffer_colorcodes, buffer_size );
+ kfree( buffer_attributes, buffer_size );
+ kfree( buffer_characters, buffer_size );
+ kfree( buffer_colorcodes, buffer_size );
}
else
{
buffer_characters == NULL ||
buffer_colorcodes == NULL )
{
- if ( buffer_attributes ) kfree( (vm_offset_t)buffer_attributes, buffer_size );
- if ( buffer_characters ) kfree( (vm_offset_t)buffer_characters, buffer_size );
- if ( buffer_colorcodes ) kfree( (vm_offset_t)buffer_colorcodes, buffer_size );
+ if ( buffer_attributes ) kfree( buffer_attributes, buffer_size );
+ if ( buffer_characters ) kfree( buffer_characters, buffer_size );
+ if ( buffer_colorcodes ) kfree( buffer_colorcodes, buffer_size );
buffer_columns = 0;
buffer_rows = 0;
if ( gc_initialized == FALSE )
{
/* Init our lock */
- simple_lock_init(&gc_buffer_lock, ETAP_IO_TTY);
+ simple_lock_init(&gc_buffer_lock, 0);
gc_initialized = TRUE;
}
{
spl_t s;
+ if (!gc_buffer_size) return;
+
s = splhigh();
simple_lock(&gc_buffer_lock);
{
spl_t s;
+ if (!gc_buffer_size) return;
+
s = splhigh();
simple_lock(&gc_buffer_lock);
return; /* nothing to do */
}
if (vc_rendered_font) {
- kfree((vm_offset_t)vc_rendered_font, vc_rendered_font_size);
+ kfree(vc_rendered_font, vc_rendered_font_size);
}
vc_rendered_char_size = ISO_CHAR_HEIGHT * ((newdepth / 8) * ISO_CHAR_WIDTH);
static const unsigned char * vc_clut;
static const unsigned char * vc_clut8;
static unsigned char vc_revclut8[256];
-static unsigned int vc_progress_tick;
+static uint32_t vc_progress_interval;
+static uint64_t vc_progress_deadline;
+static thread_call_data_t vc_progress_call;
static boolean_t vc_needsave;
-static vm_address_t vc_saveunder;
+static void * vc_saveunder;
static vm_size_t vc_saveunder_len;
decl_simple_lock_data(,vc_progress_lock)
static void vc_blit_rect( int x, int y, int width, int height,
const unsigned char * dataPtr, const unsigned char * alphaPtr,
- vm_address_t backBuffer, boolean_t save, boolean_t static_alpha );
+ void * backBuffer, boolean_t save, boolean_t static_alpha );
static void vc_blit_rect_8( int x, int y, int width, int height,
const unsigned char * dataPtr, const unsigned char * alphaPtr,
unsigned char * backBuffer, boolean_t save, boolean_t static_alpha );
unsigned int * backBuffer, boolean_t save, boolean_t static_alpha );
extern void vc_display_icon( vc_progress_element * desc, const unsigned char * data );
extern void vc_progress_initialize( vc_progress_element * desc, const unsigned char * data, const unsigned char * clut );
-static void vc_progress_set( boolean_t enable, unsigned int initial_tick );
-static void vc_progress_task( void * arg );
+static void vc_progress_set( boolean_t enable, uint32_t delay );
+static void vc_progress_task( void * arg0, void * arg );
static void vc_blit_rect( int x, int y,
int width, int height,
const unsigned char * dataPtr,
const unsigned char * alphaPtr,
- vm_address_t backBuffer,
+ void * backBuffer,
boolean_t save, boolean_t static_alpha )
{
if(!vinfo.v_depth)
x += ((vinfo.v_width - width) / 2);
y += ((vinfo.v_height - height) / 2);
}
- vc_blit_rect( x, y, width, height, data, NULL, (vm_address_t) NULL, FALSE, TRUE );
+ vc_blit_rect( x, y, width, height, data, NULL, NULL, FALSE, TRUE );
}
}
const unsigned char * data,
const unsigned char * clut )
{
+ uint64_t abstime;
+
if( (!clut) || (!desc) || (!data))
return;
vc_clut = clut;
+ vc_progress->count * vc_progress->width * vc_progress->height;
else
vc_progress_alpha = NULL;
- vc_progress_tick = vc_progress->time * hz / 1000;
- simple_lock_init(&vc_progress_lock, ETAP_IO_TTY);
+ thread_call_setup(&vc_progress_call, vc_progress_task, NULL);
+
+ clock_interval_to_absolutetime_interval(vc_progress->time, 1000 * 1000, &abstime);
+ vc_progress_interval = abstime;
+
+ simple_lock_init(&vc_progress_lock, 0);
}
static void
-vc_progress_set( boolean_t enable, unsigned int initial_tick )
+vc_progress_set( boolean_t enable, uint32_t delay )
{
spl_t s;
- vm_address_t saveBuf = 0;
+ void *saveBuf = 0;
vm_size_t saveLen = 0;
unsigned int count;
unsigned int index;
}
}
}
- memset( (void *) saveBuf, 0x01, saveLen );
+ memset( saveBuf, 0x01, saveLen );
break;
case 16 :
vc_saveunder_len = saveLen;
saveBuf = 0;
saveLen = 0;
- timeout(vc_progress_task, (void *) 0,
- initial_tick );
+
+ clock_interval_to_deadline(delay, 1000 * 1000 * 1000 /*second scale*/, &vc_progress_deadline);
+ thread_call_enter_delayed(&vc_progress_call, vc_progress_deadline);
+
} else {
if( vc_saveunder) {
saveBuf = vc_saveunder;
vc_saveunder = 0;
vc_saveunder_len = 0;
}
- untimeout( vc_progress_task, (void *) 0 );
+
+ thread_call_cancel(&vc_progress_call);
}
}
kfree( saveBuf, saveLen );
}
-static void vc_progress_task( void * arg )
+static void vc_progress_task( void * arg0, void * arg )
{
spl_t s;
int count = (int) arg;
y += ((vinfo.v_height - height) / 2);
}
vc_blit_rect( x, y, width, height,
- NULL, data, vc_saveunder,
+ NULL, data, vc_saveunder,
vc_needsave, (0 == (4 & vc_progress->flags)) );
vc_needsave = FALSE;
- timeout( vc_progress_task, (void *) count,
- vc_progress_tick );
+ clock_deadline_for_periodic_event(vc_progress_interval, mach_absolute_time(), &vc_progress_deadline);
+ thread_call_enter1_delayed(&vc_progress_call, (void *)count, vc_progress_deadline);
}
simple_unlock(&vc_progress_lock);
splx(s);
#ifdef __i386__
#include <console/i386/text_console.h>
+#include <pexpert/i386/boot.h>
#endif /* __i386__ */
static boolean_t gc_acquired = FALSE;
static boolean_t gc_graphics_boot = FALSE;
-static unsigned int lastVideoPhys = 0;
-static unsigned int lastVideoVirt = 0;
-static unsigned int lastVideoSize = 0;
-
-#ifdef __i386__
-void
-initialize_screen(Boot_Video * boot_vinfo, unsigned int op)
-{
- if ( boot_vinfo )
- {
- vinfo.v_name[0] = 0;
- vinfo.v_width = boot_vinfo->v_width;
- vinfo.v_height = boot_vinfo->v_height;
- vinfo.v_depth = boot_vinfo->v_depth;
- vinfo.v_rowbytes = boot_vinfo->v_rowBytes;
- vinfo.v_physaddr = boot_vinfo->v_baseAddr;
- vinfo.v_baseaddr = vinfo.v_physaddr;
- vinfo.v_type = boot_vinfo->v_display;
-
- if ( (vinfo.v_type == TEXT_MODE) )
- {
- // Text mode setup by the booter.
- gc_ops.initialize = tc_initialize;
- gc_ops.enable = tc_enable;
- gc_ops.paint_char = tc_paint_char;
- gc_ops.clear_screen = tc_clear_screen;
- gc_ops.scroll_down = tc_scroll_down;
- gc_ops.scroll_up = tc_scroll_up;
- gc_ops.hide_cursor = tc_hide_cursor;
- gc_ops.show_cursor = tc_show_cursor;
- gc_ops.update_color = tc_update_color;
- }
- else
-
- {
- // Graphics mode setup by the booter.
- gc_ops.initialize = vc_initialize;
- gc_ops.enable = vc_enable;
- gc_ops.paint_char = vc_paint_char;
- gc_ops.scroll_down = vc_scroll_down;
- gc_ops.scroll_up = vc_scroll_up;
- gc_ops.clear_screen = vc_clear_screen;
- gc_ops.hide_cursor = vc_reverse_cursor;
- gc_ops.show_cursor = vc_reverse_cursor;
- gc_ops.update_color = vc_update_color;
- }
-
- gc_initialize(&vinfo);
-
-#ifdef GRATEFULDEBUGGER
- GratefulDebInit((bootBumbleC *)boot_vinfo); /* Re-initialize GratefulDeb */
-#endif /* GRATEFULDEBUGGER */
- }
-
- switch ( op )
- {
- case kPEGraphicsMode:
- panicDialogDesired = TRUE;
- gc_graphics_boot = TRUE;
- break;
-
- case kPETextMode:
- panicDialogDesired = FALSE;
- gc_graphics_boot = FALSE;
- break;
-
- case kPEAcquireScreen:
- if ( gc_acquired ) break;
-
- vc_progress_set( gc_graphics_boot, 2 * hz );
- gc_enable( !gc_graphics_boot );
- gc_acquired = TRUE;
- break;
-
- case kPEEnableScreen:
- /* deprecated */
- break;
-
- case kPETextScreen:
- panicDialogDesired = FALSE;
- if ( gc_acquired == FALSE ) break;
- if ( gc_graphics_boot == FALSE ) break;
-
- vc_progress_set( FALSE, 0 );
- gc_enable( TRUE );
- break;
-
- case kPEDisableScreen:
- /* deprecated */
- /* skip break */
-
- case kPEReleaseScreen:
- gc_acquired = FALSE;
- gc_enable( FALSE );
- vc_progress_set( FALSE, 0 );
+static unsigned int lastVideoPhys = 0;
+static unsigned int lastVideoVirt = 0;
+static unsigned int lastVideoSize = 0;
+static boolean_t lastVideoMapped = FALSE;
- vc_clut8 = NULL;
-#ifdef GRATEFULDEBUGGER
- GratefulDebInit(0); /* Stop grateful debugger */
-#endif /* GRATEFULDEBUGGER */
- break;
- }
-#ifdef GRATEFULDEBUGGER
- if ( boot_vinfo ) GratefulDebInit((bootBumbleC *)boot_vinfo); /* Re initialize GratefulDeb */
-#endif /* GRATEFULDEBUGGER */
-}
-#else
void
initialize_screen(Boot_Video * boot_vinfo, unsigned int op)
{
/*
* First, check if we are changing the size and/or location of the framebuffer
*/
-
vinfo.v_name[0] = 0;
vinfo.v_width = boot_vinfo->v_width;
vinfo.v_height = boot_vinfo->v_height;
vinfo.v_depth = boot_vinfo->v_depth;
vinfo.v_rowbytes = boot_vinfo->v_rowBytes;
vinfo.v_physaddr = boot_vinfo->v_baseAddr; /* Get the physical address */
+#ifdef __i386__
+ vinfo.v_type = boot_vinfo->v_display;
+#else
+ vinfo.v_type = 0;
+#endif
+
- kprintf("initialize_screen: b=%08X, w=%08X, h=%08X, r=%08X\n", /* (BRINGUP) */
- vinfo.v_physaddr, vinfo.v_width, vinfo.v_height, vinfo.v_rowbytes); /* (BRINGUP) */
+ kprintf("initialize_screen: b=%08X, w=%08X, h=%08X, r=%08X, d=%08X\n", /* (BRINGUP) */
+ vinfo.v_physaddr, vinfo.v_width, vinfo.v_height, vinfo.v_rowbytes, vinfo.v_type); /* (BRINGUP) */
+
+#ifdef __i386__
+ if ( (vinfo.v_type == VGA_TEXT_MODE) )
+ {
+ if (vinfo.v_physaddr == 0) {
+ vinfo.v_physaddr = 0xb8000;
+ vinfo.v_width = 80;
+ vinfo.v_height = 25;
+ vinfo.v_depth = 8;
+ vinfo.v_rowbytes = 0x8000;
+ }
+ }
+#endif /* __i386__ */
if (!vinfo.v_physaddr) /* Check to see if we have a framebuffer */
{
vinfo.v_physaddr = (fbppage << 12) | (boot_vinfo->v_baseAddr & PAGE_MASK); /* Get the physical address */
}
- vinfo.v_type = 0;
-
fbsize = round_page_32(vinfo.v_height * vinfo.v_rowbytes); /* Remember size */
if ((lastVideoPhys != vinfo.v_physaddr) || (fbsize > lastVideoSize)) /* Did framebuffer change location or get bigger? */
{
- newVideoVirt = io_map_spec((vm_offset_t)vinfo.v_physaddr, fbsize); /* Allocate address space for framebuffer */
+ unsigned int
+#if FALSE
+ flags = (vinfo.v_type == VGA_TEXT_MODE) ? VM_WIMG_IO : VM_WIMG_WCOMB;
+#else
+ flags = VM_WIMG_IO;
+#endif
+ newVideoVirt = io_map_spec((vm_offset_t)vinfo.v_physaddr, fbsize, flags); /* Allocate address space for framebuffer */
if (lastVideoVirt) /* Was the framebuffer mapped before? */
{
- pmap_remove(kernel_pmap, trunc_page_64(lastVideoVirt),
- round_page_64(lastVideoVirt + lastVideoSize)); /* Toss mappings */
-
- if(lastVideoVirt <= vm_last_addr) /* Was this not a special pre-VM mapping? */
+#if FALSE
+ if(lastVideoMapped) /* Was this not a special pre-VM mapping? */
+#endif
+ {
+ pmap_remove(kernel_pmap, trunc_page_64(lastVideoVirt),
+ round_page_64(lastVideoVirt + lastVideoSize)); /* Toss mappings */
+ }
+ if(lastVideoMapped) /* Was this not a special pre-VM mapping? */
{
kmem_free(kernel_map, lastVideoVirt, lastVideoSize); /* Toss kernel addresses */
}
}
-
lastVideoPhys = vinfo.v_physaddr; /* Remember the framebuffer address */
lastVideoSize = fbsize; /* Remember the size */
lastVideoVirt = newVideoVirt; /* Remember the virtual framebuffer address */
+ lastVideoMapped = (NULL != kernel_map);
}
}
vinfo.v_baseaddr = lastVideoVirt; /* Set the new framebuffer address */
#ifdef __i386__
- if ( (vinfo.v_type == TEXT_MODE) )
+ if ( (vinfo.v_type == VGA_TEXT_MODE) )
{
// Text mode setup by the booter.
case kPEAcquireScreen:
if ( gc_acquired ) break;
- vc_progress_set( gc_graphics_boot, 2 * hz );
+ vc_progress_set( gc_graphics_boot, kProgressAcquireDelay );
gc_enable( !gc_graphics_boot );
gc_acquired = TRUE;
break;
if ( boot_vinfo ) GratefulDebInit((bootBumbleC *)boot_vinfo); /* Re initialize GratefulDeb */
#endif /* GRATEFULDEBUGGER */
}
-#endif
void
refresh_screen(void)