Annotation of XNU/pexpert/i386/pe_printf.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  * file: pe_printf.c
                     24:  *    i386 platform expert output initialization.
                     25:  */
                     26: #include <sys/types.h>
                     27: #include <mach/vm_param.h>
                     28: #include <stdarg.h>
                     29: #include <pexpert/protos.h>
                     30: #include <pexpert/pexpert.h>
                     31: #include <pexpert/i386/kdsoft.h>
                     32: 
                     33: #define KA_NORMAL       0x07
                     34: #define COLOR_PLATNUM   0x80
                     35: 
                     36: /* extern references */
                     37: extern void printf(const char *format, ...);
                     38: extern void cninit(void);
                     39: extern void display_putc(char c);
                     40: extern void cnputc(char c);
                     41: 
                     42: /* local references */
                     43: void PE_printf(const char *fmt, ...);
                     44: unsigned char *mapframebuffer(caddr_t,int);
                     45: void (*PE_putc)(char c);
                     46: u_char *vid_start;
                     47: 
                     48: void PE_init_printf(boolean_t vm_initialized)
                     49: {
                     50:        PE_Video v;
                     51: 
                     52: 
                     53: 
                     54:     if (!vm_initialized)
                     55:     {
                     56:        /*
                     57:         * Initialize the console so we can print.  Start out by pointing to 0xa0000, but eventually
                     58:         * map our space in and then update the console "vid_start".
                     59:         */
                     60:        /* FIX ME! */
                     61:        
                     62:        vid_start = 0xa0000;
                     63:        v.v_width = PE_state.video.v_width;
                     64:         v.v_depth = PE_state.video.v_depth;
                     65:         v.v_rowBytes = PE_state.video.v_rowBytes;
                     66:        /* HACK - Only "one segment" is available on the screen  */
                     67:         v.v_height = 0x10000 / (PE_state.video.v_rowBytes);
                     68:        initialize_screen(&v, vid_start);
                     69:     }
                     70:     else
                     71:     {
                     72:        /*
                     73:         * Initialize the console so we can print.  Now that VM is initialized, map out physical
                     74:         * space in.
                     75:         */
                     76: 
                     77:        if (PE_state.video.v_baseAddr != 0)
                     78:        {
                     79:            unsigned char *fb;
                     80: 
                     81:            fb = mapframebuffer((caddr_t)PE_state.video.v_baseAddr, 
                     82:                                PE_state.video.v_rowBytes * PE_state.video.v_height);
                     83:            vid_start = fb;
                     84:            initialize_screen(&PE_state.video, vid_start);
                     85:            printf("Console initialized.  Mode: Linear (%ldx%ldx%ld)\n", PE_state.video.v_width,
                     86:                                                                      PE_state.video.v_height,
                     87:                                                                      PE_state.video.v_depth);
                     88:            init_display_putc(fb, PE_state.video.v_width * PE_state.video.v_depth / 8, PE_state.video.v_height);
                     89:            PE_putc = display_putc;
                     90:            PE_printf("Debug console initialized.\n"); PE_pause(1);
                     91:            
                     92:        }
                     93:     }
                     94: }
                     95: 
                     96: void PE_printf(const char *fmt, ...)
                     97: {
                     98:         va_list listp;
                     99: 
                    100:         va_start(listp, fmt);
                    101:        _doprnt(fmt, &listp, PE_putc, 16);
                    102:         va_end(listp);
                    103: }
                    104: 
                    105: /*
                    106:  * mapblit: map the framebuffer into kernel vm and return the (virtual)
                    107:  * address.
                    108:  */
                    109: unsigned char *
                    110: mapframebuffer(
                    111:         caddr_t physaddr,               /* start of framebuffer */
                    112:         int     length)                 /* num bytes to map */
                    113: {
                    114:         vm_offset_t vmaddr;
                    115: 
                    116:         if (physaddr != (caddr_t)trunc_page(physaddr))
                    117:                 panic("Framebuffer not on page boundary");
                    118: 
                    119:         vmaddr = io_map((vm_offset_t)physaddr, length);
                    120:         if (vmaddr == 0)
                    121:                 panic("can't alloc VM for framebuffer");
                    122: 
                    123:         return((unsigned char *)vmaddr);
                    124: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.