]>
git.saurik.com Git - apple/xnu.git/blob - pexpert/ppc/pe_kprintf.c
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
;
53 struct slock kprintf_lock
;
55 void PE_init_kprintf(boolean_t vm_initialized
)
57 unsigned int boot_arg
;
59 if (PE_state
.initialized
== FALSE
)
60 panic("Platform Expert not initialized");
62 if (PE_parse_boot_arg("debug", &boot_arg
))
63 if(boot_arg
& DB_KPRT
) disableSerialOuput
= FALSE
;
65 if( (scc
= PE_find_scc())) { /* See if we can find the serial port */
66 scc
= io_map_spec(scc
, 0x1000); /* Map it in */
67 initialize_serial((void *)scc
); /* Start up the serial driver */
68 PE_kputc
= serial_putc
;
70 simple_lock_init(&kprintf_lock
, 0);
76 * FUTURE: eventually let the boot command determine where
77 * the debug output will be, serial, video, etc.
79 switch (PE_state
.debug_video
.v_display
) {
80 case kDebugTypeSerial
:
81 PE_kputc
= serial_putc
;
84 case kDebugTypeDisplay
:
85 init_display_putc( (unsigned char*)PE_state
.debug_video
.v_baseAddr
,
86 PE_state
.debug_video
.v_rowBytes
,
87 PE_state
.debug_video
.v_height
);
88 PE_kputc
= display_putc
;
92 PE_state
.debug_video
.v_baseAddr
= 0;
97 void serial_putc(char c
)
99 (void) scc_putc(0, 1, c
);
100 if (c
== '\n') (void) scc_putc(0, 1, '\r');
103 (void) scc_putc(0, (int)PE_state
.debug_video
.v_baseAddr
, c
);
104 if (c
== '\n') (void) scc_putc(0, (int)PE_state
.debug_video
.v_baseAddr
, '\r');
108 void kprintf(const char *fmt
, ...)
113 state
= ml_set_interrupts_enabled(FALSE
);
114 simple_lock(&kprintf_lock
);
116 if (!disableSerialOuput
) {
117 va_start(listp
, fmt
);
118 _doprnt(fmt
, &listp
, PE_kputc
, 16);
122 simple_unlock(&kprintf_lock
);
123 ml_set_interrupts_enabled(state
);