|
|
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_kprintf.c ! 24: * PPC platform expert debugging output initialization. ! 25: */ ! 26: #include <stdarg.h> ! 27: #include <pexpert/protos.h> ! 28: #include <pexpert/pexpert.h> ! 29: #include <pexpert/ppc/powermac.h> ! 30: #include <kern/debug.h> ! 31: #include <kern/simple_lock.h> ! 32: ! 33: /* extern references */ ! 34: extern void init_display_putc(unsigned char*, int, int); ! 35: extern void display_putc(char c); ! 36: extern int scc_putc(int unit, int line, int c); ! 37: extern void cnputc(char c); ! 38: ! 39: /* Internal routines -- eventually put this in serial driver */ ! 40: void serial_putc(char c); ! 41: ! 42: /* Globals */ ! 43: void (*PE_kputc)(char c) = 0; ! 44: ! 45: unsigned int disableSerialOuput = TRUE; ! 46: ! 47: ! 48: static struct slock kprintf_lock; ! 49: ! 50: void PE_init_kprintf(boolean_t vm_initialized) ! 51: { ! 52: static vm_offset_t scc; ! 53: unsigned int boot_arg; ! 54: ! 55: if (PE_state.initialized == FALSE) ! 56: panic("Platform Expert not initialized"); ! 57: ! 58: if (!vm_initialized) ! 59: { ! 60: if (PE_parse_boot_arg("debug", &boot_arg)) ! 61: if(boot_arg & DB_KPRT) disableSerialOuput = FALSE; ! 62: ! 63: if( (scc = PE_find_scc())) ! 64: { ! 65: initialize_serial( (void *) scc ); ! 66: PE_kputc = serial_putc; ! 67: ! 68: simple_lock_init(&kprintf_lock, 0); ! 69: } else ! 70: PE_kputc = cnputc; ! 71: ! 72: } else if( scc){ ! 73: initialize_serial( (void *) io_map( scc, 0x1000) ); ! 74: } ! 75: ! 76: #if 0 ! 77: /* ! 78: * FUTURE: eventually let the boot command determine where ! 79: * the debug output will be, serial, video, etc. ! 80: */ ! 81: switch (PE_state.debug_video.v_display) { ! 82: case kDebugTypeSerial: ! 83: PE_kputc = serial_putc; ! 84: break; ! 85: ! 86: case kDebugTypeDisplay: ! 87: init_display_putc( (unsigned char*)PE_state.debug_video.v_baseAddr, ! 88: PE_state.debug_video.v_rowBytes, ! 89: PE_state.debug_video.v_height); ! 90: PE_kputc = display_putc; ! 91: break; ! 92: ! 93: default: ! 94: PE_state.debug_video.v_baseAddr = 0; ! 95: } ! 96: #endif ! 97: } ! 98: ! 99: void serial_putc(char c) ! 100: { ! 101: (void) scc_putc(0, 1, c); ! 102: if (c == '\n') (void) scc_putc(0, 1, '\r'); ! 103: ! 104: #if 0 ! 105: (void) scc_putc(0, (int)PE_state.debug_video.v_baseAddr, c); ! 106: if (c == '\n') (void) scc_putc(0, (int)PE_state.debug_video.v_baseAddr, '\r'); ! 107: #endif ! 108: } ! 109: ! 110: void kprintf(const char *fmt, ...) ! 111: { ! 112: va_list listp; ! 113: boolean_t state; ! 114: ! 115: state = ml_set_interrupts_enabled(FALSE); ! 116: simple_lock(&kprintf_lock); ! 117: ! 118: if (!disableSerialOuput) { ! 119: va_start(listp, fmt); ! 120: _doprnt(fmt, &listp, PE_kputc, 16); ! 121: va_end(listp); ! 122: } ! 123: ! 124: simple_unlock(&kprintf_lock); ! 125: ml_set_interrupts_enabled(state); ! 126: } ! 127:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.