UbixOS V2 2.0

sde.cc
Go to the documentation of this file.
1 /*-
2 * Copyright (c) 2002-2018 The UbixOS Project.
3 * All rights reserved.
4 *
5 * This was developed by Christopher W. Olsen for the UbixOS Project.
6 *
7 * Redistribution and use in source and binary forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
10 * 1) Redistributions of source code must retain the above copyright notice, this list of
11 * conditions, the following disclaimer and the list of authors.
12 * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13 * conditions, the following disclaimer and the list of authors in the documentation and/or
14 * other materials provided with the distribution.
15 * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16 * endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 extern "C" {
30 #include <sys/types.h>
31 #include <sys/video.h>
32 #include <ubixos/sched.h>
33 #include <ubixos/vitals.h>
34 #include <lib/kprintf.h>
35 #include <lib/kmalloc.h>
36 #include <string.h>
37 }
38
39 #include <sde/sde.h>
40 #include <sde/ogDisplay_UbixOS.h>
41 #include <objgfx40/objgfx40.h>
42
43 struct sdeWindows *windows = 0x0;
44
45 extern "C" int sysSDE(struct thread *td, struct sys_sde_args *args) {
46
47 ogSurface *newBuf = 0x0;
48 ogSurface *oldBuf = (ogSurface *)args->ptr;
49 ogSurface *screen = 0x0;
50
51 struct sdeWindows *tmp = 0x0;
52
53 screen = (ogDisplay_UbixOS *) systemVitals->screen;
54
55 for (tmp = windows; tmp; tmp = tmp->next) {
56 if (tmp->pid == (int) _current->id)
57 break;
58 }
59
60 if (tmp != 0x0) {
61 while (tmp->status != windowReady)
62 asm("hlt");
63 }
64 else if (tmp == 0x0 && args->cmd != registerWindow) {
65 if (args->cmd == drawWindow) {
66 //screen->ogCopyBuf(screen->ogGetMaxX() - oldBuf->ogGetMaxX(), screen->ogGetMaxY() - oldBuf->ogGetMaxY(), *oldBuf, 0, 0, oldBuf->ogGetMaxX(), oldBuf->ogGetMaxY());
67 }
68
69 //kprintf("Invalid Window\n");
70 td->td_retval[0] = -1;
71 return(-1);
72 }
73
74 switch (args->cmd) {
75 case drawWindow:
76 /*
77 screen->ogCopyBuf(screen->ogGetMaxX() - oldBuf->ogGetMaxX(), screen->ogGetMaxY() - oldBuf->ogGetMaxY(), *oldBuf, 0, 0, oldBuf->ogGetMaxX(), oldBuf->ogGetMaxY());
78 kprintf("Draw Window\n");
79 while(1) asm("nop");
80 */
81
82 tmp->status = drawWindow;
83 while (tmp->status != windowReady) {
84 asm("nop");
85 //asm("hlt");
86 }
87 break;
88 case killWindow:
89 tmp->status = killWindow;
90 break;
91 case registerWindow:
92 if (oldBuf->buffer != 0x0) {
93 newBuf = new ogSurface();
94 newBuf->version = oldBuf->version;
95 newBuf->buffer = oldBuf->buffer;
96 newBuf->owner = oldBuf->owner;
97 newBuf->lineOfs = oldBuf->lineOfs;
98 newBuf->pal = oldBuf->pal;
99 newBuf->attributes = oldBuf->attributes;
100 newBuf->xRes = oldBuf->xRes;
101 newBuf->yRes = oldBuf->yRes;
102 newBuf->maxX = oldBuf->maxX;
103 newBuf->maxY = oldBuf->maxY;
104 newBuf->bSize = oldBuf->bSize;
105 newBuf->lSize = oldBuf->lSize;
106 newBuf->BPP = oldBuf->BPP;
107 newBuf->bytesPerPix = oldBuf->bytesPerPix;
108 newBuf->pixFmtID = oldBuf->pixFmtID;
109 newBuf->redFieldPosition = oldBuf->redFieldPosition;
110 newBuf->greenFieldPosition = oldBuf->greenFieldPosition;
111 newBuf->blueFieldPosition = oldBuf->blueFieldPosition;
112 newBuf->alphaFieldPosition = oldBuf->alphaFieldPosition;
113 newBuf->redShifter = oldBuf->redShifter;
114 newBuf->greenShifter = oldBuf->greenShifter;
115 newBuf->blueShifter = oldBuf->blueShifter;
116 newBuf->alphaShifter = oldBuf->alphaShifter;
117 newBuf->lastError = oldBuf->lastError;
118 newBuf->dataState = oldBuf->dataState;
119 tmp = (struct sdeWindows *) kmalloc(sizeof(struct sdeWindows));
120 tmp->buf = newBuf;
121 tmp->status = registerWindow;
122 tmp->pid = _current->id;
123 tmp->prev = 0x0;
124 if (windows == 0x0) {
125 windows = tmp;
126 tmp->next = 0x0;
127 }
128 else {
129 tmp->next = windows;
130 windows->prev = tmp;
131 windows = tmp;
132 }
133 }
134 else {
135 kprintf("Invalid Window\n");
136 }
137 break;
138 default:
139 kprintf("Invalid SDE Command [0x%X]\n", args->ptr);
140 break;
141 }
142
143 td->td_retval[0] = 0;
144 return(0);
145 }
146
147 /***
148 END
149 ***/
150
windows
struct sdeWindows * windows
Definition: sde.cc:43
sdeWindows::next
struct sdeWindows * next
Definition: sde.h:49
sys_sde_args::cmd
uint32_t cmd
Definition: sysproto.h:82
string.h
ogDisplay_UbixOS.h
video.h
thread
Definition: thread.h:40
sched.h
drawWindow
#define drawWindow
Definition: sde.h:40
types.h
sysSDE
int sysSDE(struct thread *td, struct sys_sde_args *args)
Definition: sde.cc:45
sys_sde_args::ptr
uint32_t ptr
Definition: sysproto.h:85
taskStruct::id
pidType id
Definition: sched.h:63
ogDisplay_UbixOS
Definition: ogDisplay_UbixOS.h:89
registerWindow
#define registerWindow
Definition: sde.h:38
thread::td_retval
int td_retval[2]
Definition: thread.h:41
systemVitals
vitalsNode * systemVitals
Definition: vitals.c:35
kprintf.h
vitals.h
windowReady
#define windowReady
Definition: sde.h:39
killWindow
#define killWindow
Definition: sde.h:41
_current
kTask_t * _current
Definition: sched.c:50
sdeWindows
Definition: sde.h:48
kmalloc
void * kmalloc(uInt32 len)
Definition: kmalloc.c:241
sde.h
sdeWindows::prev
struct sdeWindows * prev
Definition: sde.h:50
sys_sde_args
Definition: sysproto.h:80
kprintf
int kprintf(const char *,...)
Definition: kprintf.c:259
vitalsStruct::screen
void * screen
Definition: vitals.h:47
kmalloc.h