1 /* tag: openbios qt plugin skeleton
2  *
3  * Copyright (C) 2003 Stefan Reinauer
4  *
5  * See the file "COPYING" for further information about
6  * the copyright and warranty status of this work.
7  */
8 
9 
10 extern "C" {
11 #include <pthread.h>
12 #include <unistd.h>
13 #include "unix/plugins.h"
14 #include "unix/plugin_pci.h"
15 }
16 #include "plugin_qt.h"
17 #include "pciconfig.h"
18 #include "fcode.h"
19 
20 #define DEBUG
21 
22 volatile unsigned char * fb=0;
23 volatile int gui_running=0;
24 
25 typedef struct {
26 	int argc;
27 	char **argv;
28 } threaddata;
29 
gui_thread(void * ptr)30 void *gui_thread(void *ptr)
31 {
32 	threaddata *td=(threaddata *)ptr;
33 
34 	QApplication a(td->argc, td->argv);
35 	FrameBufferWidget w;
36 
37 	a.setMainWidget(&w);
38 	w.show();
39 
40 	fb=w.getFrameBuffer();
41 
42 	gui_running=-1;
43 	a.exec();
44 	gui_running=0;
45 
46 	return 0;
47 }
48 
49 extern "C" {
50 extern int plugin_qt_init(void);
plugin_qt_init(void)51 int plugin_qt_init(void)
52 {
53 	pthread_t mythread;
54 	char *args[]={ "plugin_qt" };
55 	threaddata mytd = { 1, args };
56 
57 #ifdef DEBUG
58 	printf("Initializing \"framebuffer\" plugin...");
59 #endif
60 	pthread_create(&mythread, NULL, gui_thread, &mytd);
61 	while (!fb)
62 		usleep(20);
63 
64 	/* now we have the framebuffer start address.
65 	 * updating pci config space to reflect this
66 	 */
67 #if (BITS > 32)
68 	*(u32 *)(pci_config_space+0x14)=(u32)((unsigned long)fb>>32);
69 #else
70 	*(u32 *)(pci_config_space+0x14)=0;
71 #endif
72 	*(u32 *)(pci_config_space+0x10)=(u32)((unsigned long)fb&0xffffffff);
73 
74 	/* next is to write the rom address. We write that at a random
75 	 * address in pci config space for now.
76 	 */
77 #if (BITS > 32)
78 	*(u32 *)(pci_config_space+0x34)=(u32)((unsigned long)qt_fcode>>32);
79 #else
80 	*(u32 *)(pci_config_space+0x34)=0;
81 #endif
82 	*(u32 *)(pci_config_space+0x30)=(u32)((unsigned long)qt_fcode&0xffffffff);
83 
84 	/* FIXME: we need to put the fcode image for this
85 	 * device to the rom resource, once it exists
86 	 */
87 
88 	/* register pci device to be available to beginagain */
89 	pci_register_device(0, 2, 0, pci_config_space);
90 
91 #ifdef DEBUG
92 	printf("done.\n");
93 #endif
94 	return 0;
95 }
96 
97 PLUGIN_AUTHOR("Stefan Reinauer <stefan.reinauer@coreboot.org>")
98 PLUGIN_DESCRIPTION("QT gui plugin emulating framebuffer device")
99 PLUGIN_LICENSE("GPL v2")
100 PLUGIN_DEPENDENCIES("pci")
101 
102 }
103