version 2.8
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.org/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  #undef Red
63  #undef Green
64  #undef Blue
65  #define WIN32_LEAN_AND_MEAN
66  #include <windows.h>
67  #undef WIN32_LEAN_AND_MEAN
68  #define Blue HTML2COLOR(0x0000FF)
69  #define Red HTML2COLOR(0xFF0000)
70  #define Green HTML2COLOR(0x008000)
71 
72  #include <stdio.h>
73  systemticks_t gfxSystemTicks(void) { return GetTickCount(); }
74  systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; }
75 #endif
76 
77 /*********************************************************
78  * Exit everything functions
79  *********************************************************/
80 
81 void gfxHalt(const char *msg) {
82  #if defined(WIN32)
83  fprintf(stderr, "%s\n", msg);
84  ExitProcess(1);
85  #else
86  volatile uint32_t dummy;
87  (void) msg;
88 
89  while(1)
90  dummy++;
91  #endif
92 }
93 
94 void gfxExit(void) {
95  #if defined(WIN32)
96  ExitProcess(0);
97  #else
98  volatile uint32_t dummy;
99 
100  while(1)
101  dummy++;
102  #endif
103 }
104 
105 #endif /* GFX_USE_OS_RAW32 */
systemticks_t gfxSystemTicks(void)
Get the current operating system tick time.
systemticks_t gfxMillisecondsToTicks(delaytime_t 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.