UbixOS  2.0
main.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 //#include <ubixos/sched.h>
30 //#include <lib/kprintf.h>
31 //#include <vmm/paging.h>
32 //#include <lib/bioscall.h>
33 
34 extern "C" {
35 #include <lib/kprintf.h>
36 #include <ubixos/vitals.h>
37 #include <ubixos/exec.h>
38 #include <vmm/vmm.h>
39 #include <lib/kmalloc.h>
40 }
41 
42 #include <sde/sde.h>
43 #include <objgfx40/objgfx40.h>
44 #include <sde/ogDisplay_UbixOS.h>
45 #include <objgfx40/ogFont.h>
46 
47 void sdeTestThread();
48 
49 extern "C" void sdeThread();
50 
51 void sdeThread() {
52  ogSurface *screen = new ogDisplay_UbixOS();
53 
54 
55  struct sdeWindows *tmp = 0x0;
56  ogSurface *buf = 0x0;
57  ogBitFont * font = new ogBitFont();
58 
59 
60  font->Load("/var/fonts/ROM8X14.DPF", 0);
61  font->SetFGColor(255, 255, 255, 255);
62  font->SetBGColor(0, 0, 0, 255);
63 
64  printOff = 0x1;
65 
66  screen->ogCreate(800, 600, OG_PIXFMT_24BPP);
67 
68  //screen->ogClear(screen->ogPack(122, 140, 163));
69  //screen->ogClear(screen->ogPack(0x66, 0xE0, 0xFF));
70  screen->ogClear(screen->ogPack(0x92, 0xA8, 0xD1));
71 
72  systemVitals->screen = screen;
73  systemVitals->font = font;
74 
75  ogprintOff = (int) 0x0;
76 
77  screen->ogSetAntiAliasing(false);
78 
79  execThread(&sdeTestThread, 0x2000, 0x0);
80 
81  //ogSurface::RawLine(100, 100, 200, 200, 0xDEADBEEF)
82  //screen->RawLine(100, 100, 200, 200, 0xDEADBEEF);
83 
84  //font->PutChar(*screen, 100, 100, 'A' - 2);
85  //font->PutChar(*screen, 100, 120, 'a');
86 
87  while (1) {
88  for (tmp = windows; tmp; tmp = tmp->next) {
89  switch (tmp->status) {
90  case registerWindow:
91  kprintf("buf->buffer 0x%X, buf->bSize: 0x%X", buf->buffer, buf->bSize);
92  buf = (ogSurface *) tmp->buf;
93  buf->buffer = (void *) vmm_mapFromTask(tmp->pid, buf->buffer, buf->bSize);
94  if (buf->buffer == 0x0) {
95  kprintf("Error: buf->buffer\n");
96  while (1)
97  asm("nop");
98  }
99 
100 
101  kprintf("buf->lineOfs 0x%X, buf->lSize: 0x%X", buf->lineOfs, buf->lSize);
102  buf->lineOfs = (uInt32 *) vmm_mapFromTask(tmp->pid, buf->lineOfs, buf->lSize);
103  if (buf->lineOfs == 0x0) {
104  kprintf("Error: buf->lineOfs\n");
105  while (1)
106  ;
107  }
108  tmp->status = windowReady;
109  //kprintf("Window Registered!\n");
110  break;
111  case drawWindow:
112  buf = (ogSurface *) tmp->buf;
113  screen->ogCopyBuf(screen->ogGetMaxX() - buf->ogGetMaxX(), screen->ogGetMaxY() - buf->ogGetMaxY(), *buf, 0, 0, buf->ogGetMaxX(), buf->ogGetMaxY());
114  tmp->status = windowReady;
115  kprintf("Draw Window Routines Here: %i-%i\n", buf->ogGetMaxX(), buf->ogGetMaxY());
116  break;
117  case killWindow:
118  //kprintf("Killed Window\n");
119  if (tmp->next != 0x0) {
120  tmp->next->prev = tmp->prev;
121  if (tmp->prev != 0x0)
122  tmp->prev->next = tmp->next;
123  }
124  else if (tmp->prev != 0x0) {
125  tmp->prev->next = tmp->next;
126  if (tmp->next != 0x0)
127  tmp->next->prev = tmp->prev;
128  }
129  else {
130  windows = 0x0;
131  }
132  vmm_unmapPages(buf->buffer, buf->bSize, VMM_KEEP);
133  vmm_unmapPages(buf->lineOfs, buf->lSize, VMM_KEEP);
134  kfree(tmp);
135  tmp = 0x0;
136  break;
137  default:
138  sched_yield();
139  break;
140  }
141  }
142  }
143 }
ogprintOff
int ogprintOff
Definition: kprintf.c:257
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
sdeWindows::next
struct sdeWindows * next
Definition: sde.h:49
ogDisplay_UbixOS.h
kfree
void kfree(void *baseAddr)
Definition: kmalloc.c:342
sdeWindows::status
uint8_t status
Definition: sde.h:53
vmm.h
exec.h
drawWindow
#define drawWindow
Definition: sde.h:40
ogDisplay_UbixOS
Definition: ogDisplay_UbixOS.h:89
registerWindow
#define registerWindow
Definition: sde.h:38
systemVitals
vitalsNode * systemVitals
Definition: vitals.c:35
kprintf.h
buf
Definition: buf.h:35
vitals.h
windowReady
#define windowReady
Definition: sde.h:39
execThread
uInt32 execThread(void(*tproc)(void), uInt32 stack, char *arg)
Definition: exec.c:66
killWindow
#define killWindow
Definition: sde.h:41
vitalsStruct::font
void * font
Definition: vitals.h:48
sdeWindows::buf
void * buf
Definition: sde.h:51
vmm_unmapPages
void vmm_unmapPages(void *, uint32_t, unmapFlags_t)
Definition: unmappage.c:99
VMM_KEEP
Definition: vmm.h:111
sdeWindows
Definition: sde.h:48
sde.h
sdeWindows::pid
pidType pid
Definition: sde.h:52
sdeWindows::prev
struct sdeWindows * prev
Definition: sde.h:50
printOff
int printOff
Definition: kprintf.c:256
kprintf
int kprintf(const char *,...)
Definition: kprintf.c:259
vitalsStruct::screen
void * screen
Definition: vitals.h:47
vmm_mapFromTask
void * vmm_mapFromTask(pidType, void *, uint32_t)
Definition: paging.c:372
windows
struct sdeWindows * windows
Definition: sde.cc:43
kmalloc.h
sdeThread
void sdeThread()
Definition: main.cc:51
sdeTestThread
void sdeTestThread()
Definition: colours.cc:42
sched_yield
void sched_yield()
Definition: sched.c:244