4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/types.h>
27 #include <sys/systm.h>
28 #include <sys/bootconf.h>
29 #include <sys/thread.h>
31 #include <sys/sunddi.h>
32 #include <vm/seg_kmem.h>
35 #include <sys/sunldi.h>
37 #define VIDEOMEM 0xa0000
39 extern void outb(int, uchar_t
);
41 static int graphics_mode
;
42 static int cursor_y
= 309;
43 static int cursor_x
= 136;
47 static uchar_t bar
[BAR_STEPS
];
48 static kthread_t
*progressbar_tid
;
49 static kmutex_t pbar_lock
;
50 static kcondvar_t pbar_cv
;
51 static char *videomem
= (caddr_t
)VIDEOMEM
;
52 static int videomem_size
;
54 /* select the plane(s) to draw to */
70 progressbar_show(void)
75 offset
= cursor_y
* 80 + cursor_x
/ 8;
76 mem
= (uchar_t
*)videomem
+ offset
;
79 mapmask(0xff); /* write to all planes at once? */
80 for (j
= 0; j
< 4; j
++) { /* bar height: 4 pixels */
82 for (k
= 0; k
< BAR_STEPS
; k
++, ptr
++)
89 * Initialize a rectangle area for progress bar
91 * Multiboot has initialized graphics mode to 640x480
100 /* see if we are in graphics mode */
101 if (BOP_GETPROPLEN(bootops
, "console") != sizeof ("graphics"))
103 (void) BOP_GETPROP(bootops
, "console", cons
);
104 if (strncmp(cons
, "graphics", strlen("graphics")) != 0)
106 if (BOP_GETPROPLEN(bootops
, "efi-systab") > 0)
111 for (i
= 0; i
< BAR_STEPS
; i
++) {
121 static int limit
= 0;
126 bar
[limit
- 4] = 0x00;
128 bar
[limit
+ BAR_STEPS
- 4] = 0x00;
131 if (limit
== BAR_STEPS
)
139 progressbar_thread(void *arg
)
141 clock_t end
= drv_usectohz(150000);
143 mutex_enter(&pbar_lock
);
144 while (graphics_mode
) {
146 (void) cv_reltimedwait(&pbar_cv
, &pbar_lock
, end
,
149 mutex_exit(&pbar_lock
);
153 progressbar_start(void)
155 extern pri_t minclsyspri
;
157 if (graphics_mode
== 0)
160 /* map video memory to kernel heap */
161 videomem_size
= ptob(btopr(38400)); /* 640 x 480 / 8 bytes */
162 videomem
= vmem_alloc(heap_arena
, videomem_size
, VM_SLEEP
);
163 if (videomem
== NULL
) {
164 cmn_err(CE_NOTE
, "!failed to start progress bar");
168 hat_devload(kas
.a_hat
, videomem
, videomem_size
,
169 btop(VIDEOMEM
), (PROT_READ
| PROT_WRITE
),
170 HAT_LOAD_NOCONSIST
| HAT_LOAD_LOCK
);
172 progressbar_tid
= thread_create(NULL
, 0, progressbar_thread
,
173 NULL
, 0, &p0
, TS_RUN
, minclsyspri
);
177 progressbar_stop(void)
179 if (graphics_mode
== 0)
183 mutex_enter(&pbar_lock
);
185 mutex_exit(&pbar_lock
);
186 if (progressbar_tid
!= NULL
)
187 thread_join(progressbar_tid
->t_did
);
189 /* unmap video memory */
190 hat_unload(kas
.a_hat
, videomem
, videomem_size
, HAT_UNLOAD_UNLOCK
);
191 vmem_free(heap_arena
, videomem
, videomem_size
);
196 progressbar_key_abort(ldi_ident_t li
)
202 extern char *consconfig_get_plat_fbpath(void);
204 if (graphics_mode
== 0)
207 fbpath
= consconfig_get_plat_fbpath();
209 if (ldi_open_by_name(fbpath
, FWRITE
, kcred
, &hdl
, li
) != 0) {
210 cmn_err(CE_NOTE
, "!ldi_open_by_name failed");
212 if (ldi_ioctl(hdl
, KDSETMODE
, KD_RESETTEXT
, FKIOCTL
,
216 "!ldi_ioctl for KD_RESETTEXT failed");
217 (void) ldi_close(hdl
, 0, kcred
);