Rev 1163 | Rev 1165 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1163 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Giacomo Guidi <giacomo@gandalf.sssup.it> |
||
10 | * |
||
11 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
12 | * |
||
13 | * http://www.sssup.it |
||
14 | * http://retis.sssup.it |
||
15 | * http://shark.sssup.it |
||
16 | */ |
||
17 | |||
18 | /* |
||
19 | * Copyright (C) 2003 Giacomo Guidi |
||
20 | * |
||
21 | * This program is free software; you can redistribute it and/or modify |
||
22 | * it under the terms of the GNU General Public License as published by |
||
23 | * the Free Software Foundation; either version 2 of the License, or |
||
24 | * (at your option) any later version. |
||
25 | * |
||
26 | * This program is distributed in the hope that it will be useful, |
||
27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
29 | * GNU General Public License for more details. |
||
30 | * |
||
31 | * You should have received a copy of the GNU General Public License |
||
32 | * along with this program; if not, write to the Free Software |
||
33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
34 | */ |
||
35 | |||
36 | #include "kernel/kern.h" |
||
37 | #include <drivers/fg.h> |
||
38 | #include <drivers/vga.h> |
||
39 | #include <drivers/keyb.h> |
||
40 | #include <unistd.h> |
||
41 | #include <stdlib.h> |
||
42 | |||
43 | #define WIDTH 640 |
||
44 | #define HEIGHT 480 |
||
45 | #define BYTES_PP 2 |
||
46 | #define INITSTR G640x480x64K //SVGAlib standard mode definitions |
||
47 | #define CARD VESA //Video driver |
||
48 | |||
49 | unsigned char *video_buf = NULL; //Video Buffer |
||
50 | unsigned long int VMEMLONG = WIDTH * HEIGHT * BYTES_PP / 4; // Used by copy_videomem_16to16 |
||
51 | unsigned long int RGB565MEM = WIDTH * HEIGHT * BYTES_PP; // Total video mem |
||
52 | |||
1164 | giacomo | 53 | #define FG_PERIOD 50000 |
54 | #define FG_WCET 30000 |
||
55 | #define FG_W 400 |
||
56 | #define FG_H 300 |
||
1163 | giacomo | 57 | |
58 | static int screen(int mode) |
||
59 | { |
||
60 | |||
61 | vga_modeinfo *minf; |
||
62 | |||
63 | vga_setmode(mode,CARD); |
||
64 | minf = vga_getmodeinfo(mode); |
||
65 | if(! (minf->flags & CAPABLE_LINEAR)){ |
||
66 | vga_setmode(TEXT,CARD); |
||
67 | printk(KERN_INFO "The mode %d is not capable of linear\n",mode); |
||
68 | return 1; |
||
69 | } |
||
70 | vga_setpage(0); |
||
71 | if(vga_setlinearaddressing() == -1) { |
||
72 | vga_setmode(TEXT,CARD); |
||
73 | printk(KERN_INFO "Could not set linear addressing for mode %d\n",mode); |
||
74 | return 1; |
||
75 | } |
||
76 | |||
77 | video_buf = vga_getgraphmem(); |
||
78 | |||
79 | memset(video_buf, 0, RGB565MEM); |
||
80 | |||
81 | grx_setbuffer(video_buf, WIDTH, HEIGHT); //Init of RGBA version of grx functions |
||
82 | //created to work with Mesa buffer |
||
83 | return 0; |
||
84 | |||
85 | } |
||
86 | |||
87 | void program_end(void *arg) |
||
88 | { |
||
1164 | giacomo | 89 | |
90 | FG_close(); |
||
91 | |||
1163 | giacomo | 92 | vga_setmode(TEXT,CARD); |
93 | |||
94 | sys_end(); |
||
95 | |||
96 | } |
||
97 | |||
98 | void program_key_end(KEY_EVT *k) |
||
99 | { |
||
100 | |||
101 | sys_end(); |
||
102 | |||
103 | } |
||
104 | |||
1164 | giacomo | 105 | void elaborate_image(void *imageptr) |
1163 | giacomo | 106 | { |
107 | |||
108 | WORD col,x,y; |
||
109 | |||
110 | while(1) { |
||
111 | |||
1164 | giacomo | 112 | for(y = 0; y < FG_H; y++) |
113 | for(x = 0; x < FG_W; x++) { |
||
1163 | giacomo | 114 | |
1164 | giacomo | 115 | col = *(BYTE *)(imageptr + y*FG_W + x); |
1163 | giacomo | 116 | *(WORD *)(video_buf + y*(WIDTH*2) + x*2) = (WORD)rgb16(col,col,col); |
117 | |||
118 | } |
||
119 | |||
120 | task_endcycle(); |
||
121 | |||
122 | } |
||
123 | |||
124 | sys_end(); |
||
125 | |||
126 | } |
||
127 | |||
128 | int main(int argc, char **argv) |
||
129 | { |
||
130 | |||
131 | sys_atrunlevel(program_end,NULL, RUNLEVEL_BEFORE_EXIT); |
||
132 | |||
133 | { |
||
134 | KEY_EVT k; |
||
135 | k.flag = ALTL_BIT; |
||
136 | k.scan = KEY_C; |
||
137 | k.ascii = 'c'; |
||
138 | keyb_hook(k,program_key_end); |
||
139 | } |
||
140 | |||
141 | screen(INITSTR); |
||
142 | |||
1164 | giacomo | 143 | FG_init(FG_PERIOD, FG_WCET, FG_W, FG_H); |
1163 | giacomo | 144 | |
1164 | giacomo | 145 | FG_set_hook(elaborate_image); |
1163 | giacomo | 146 | |
147 | return 0; |
||
148 | |||
149 | } |