µGFX  2.9
version 2.9
gos_raw32.c
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.io/license.html
6  */
7 
8 // We need to include stdio.h below for Win32 emulation. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts
9 #define GFILE_NEED_STDIO_MUST_BE_OFF
10 
11 #include "../../gfx.h"
12 
13 #if GFX_USE_OS_RAW32
14 
15 void _gosHeapInit(void);
16 void _gosThreadsInit(void);
17 
18 /*********************************************************
19  * Initialise
20  *********************************************************/
21 
22 void _gosInit(void)
23 {
24  /* No initialization of the operating system itself is needed as there isn't one.
25  * On the other hand the C runtime should still already be initialized before
26  * getting here!
27  */
28  #if !GFX_OS_INIT_NO_WARNING
29  #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
30  #warning "GOS: Raw32 - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!"
31  #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
32  COMPILER_WARNING("GOS: Raw32 - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!")
33  #endif
34  #endif
35 
36  // Set up the heap allocator
37  _gosHeapInit();
38 
39  // Start the scheduler
40  _gosThreadsInit();
41 }
42 
43 void _gosPostInit(void)
44 {
45 }
46 
47 void _gosDeinit(void)
48 {
49  /* ToDo */
50 }
51 
52 /*********************************************************
53  * For Win32 emulation - automatically add the tick functions
54  * the user would normally have to provide for bare metal.
55  *********************************************************/
56 
57 #if defined(WIN32)
58  // Win32 nasty stuff - we have conflicting definitions for Red, Green & Blue
59  #ifndef _WIN32_WINNT
60  #define _WIN32_WINNT 0x0501 // Windows XP and up
61  #endif
62  #if GFX_COMPAT_V2 && GFX_COMPAT_OLDCOLORS
63  #undef Red
64  #undef Green
65  #undef Blue
66  #endif
67  #define WIN32_LEAN_AND_MEAN
68  #include <windows.h>
69  #undef WIN32_LEAN_AND_MEAN
70  #if GFX_COMPAT_V2 && GFX_COMPAT_OLDCOLORS
71  #define Red GFX_RED
72  #define Green GFX_GREEN
73  #define Blue GFX_BLUE
74  #endif
75 
76  #include <stdio.h>
77  gTicks gfxSystemTicks(void) { return GetTickCount(); }
78  gTicks gfxMillisecondsToTicks(gDelay ms) { return ms; }
79 #endif
80 
81 /*********************************************************
82  * Exit everything functions
83  *********************************************************/
84 
85 void gfxHalt(const char *msg) {
86  #if defined(WIN32)
87  fprintf(stderr, "%s\n", msg);
88  ExitProcess(1);
89  #else
90  volatile gU32 dummy;
91  (void) msg;
92 
93  while(1)
94  dummy++;
95  #endif
96 }
97 
98 void gfxExit(void) {
99  #if defined(WIN32)
100  ExitProcess(0);
101  #else
102  volatile gU32 dummy;
103 
104  while(1)
105  dummy++;
106  #endif
107 }
108 
109 #endif /* GFX_USE_OS_RAW32 */
gTicks gfxSystemTicks(void)
Get the current operating system tick time.
gTicks gfxMillisecondsToTicks(gDelay ms)
Convert a given number of millseconds to a number of operating system ticks.
void gfxExit(void)
Exit the GFX application.
void gfxHalt(const char *msg)
Halt the GFX application due to an error.