]>
git.saurik.com Git - apple/xnu.git/blob - pexpert/ppc/pe_kprintf.c
335d52db4288ef0837e8e4548515e1f2716f8315
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * PPC platform expert debugging output initialization.
30 #include <machine/machine_routines.h>
31 #include <pexpert/protos.h>
32 #include <pexpert/pexpert.h>
33 #include <pexpert/ppc/powermac.h>
34 #include <kern/debug.h>
35 #include <kern/simple_lock.h>
37 /* extern references */
38 extern void init_display_putc(unsigned char*, int, int);
39 extern void display_putc(char c
);
40 extern int scc_putc(int unit
, int line
, int c
);
41 extern void cnputc(char c
);
43 /* Internal routines -- eventually put this in serial driver */
44 void serial_putc(char c
);
47 void (*PE_kputc
)(char c
) = 0;
49 unsigned int disableSerialOuput
= TRUE
;
52 static struct slock kprintf_lock
;
54 void PE_init_kprintf(boolean_t vm_initialized
)
56 static vm_offset_t scc
;
57 unsigned int boot_arg
;
59 if (PE_state
.initialized
== FALSE
)
60 panic("Platform Expert not initialized");
64 if (PE_parse_boot_arg("debug", &boot_arg
))
65 if(boot_arg
& DB_KPRT
) disableSerialOuput
= FALSE
;
67 if( (scc
= PE_find_scc()))
69 initialize_serial( (void *) scc
);
70 PE_kputc
= serial_putc
;
72 simple_lock_init(&kprintf_lock
, 0);
77 initialize_serial( (void *) io_map( scc
, 0x1000) );
82 * FUTURE: eventually let the boot command determine where
83 * the debug output will be, serial, video, etc.
85 switch (PE_state
.debug_video
.v_display
) {
86 case kDebugTypeSerial
:
87 PE_kputc
= serial_putc
;
90 case kDebugTypeDisplay
:
91 init_display_putc( (unsigned char*)PE_state
.debug_video
.v_baseAddr
,
92 PE_state
.debug_video
.v_rowBytes
,
93 PE_state
.debug_video
.v_height
);
94 PE_kputc
= display_putc
;
98 PE_state
.debug_video
.v_baseAddr
= 0;
103 void serial_putc(char c
)
105 (void) scc_putc(0, 1, c
);
106 if (c
== '\n') (void) scc_putc(0, 1, '\r');
109 (void) scc_putc(0, (int)PE_state
.debug_video
.v_baseAddr
, c
);
110 if (c
== '\n') (void) scc_putc(0, (int)PE_state
.debug_video
.v_baseAddr
, '\r');
114 void kprintf(const char *fmt
, ...)
119 state
= ml_set_interrupts_enabled(FALSE
);
120 simple_lock(&kprintf_lock
);
122 if (!disableSerialOuput
) {
123 va_start(listp
, fmt
);
124 _doprnt(fmt
, &listp
, PE_kputc
, 16);
128 simple_unlock(&kprintf_lock
);
129 ml_set_interrupts_enabled(state
);