µGFX library fork

gos_raw32.c 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. // We need to include stdio.h below for Win32 emulation. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts
  8. #define GFILE_NEED_STDIO_MUST_BE_OFF
  9. #include "../../gfx.h"
  10. #if GFX_USE_OS_RAW32
  11. void _gosHeapInit(void);
  12. void _gosThreadsInit(void);
  13. /*********************************************************
  14. * Initialise
  15. *********************************************************/
  16. void _gosInit(void)
  17. {
  18. /* No initialization of the operating system itself is needed as there isn't one.
  19. * On the other hand the C runtime should still already be initialized before
  20. * getting here!
  21. */
  22. #if !GFX_OS_INIT_NO_WARNING
  23. #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
  24. #warning "GOS: Raw32 - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!"
  25. #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
  26. COMPILER_WARNING("GOS: Raw32 - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!")
  27. #endif
  28. #endif
  29. // Set up the heap allocator
  30. _gosHeapInit();
  31. // Start the scheduler
  32. _gosThreadsInit();
  33. }
  34. void _gosPostInit(void)
  35. {
  36. }
  37. void _gosDeinit(void)
  38. {
  39. /* ToDo */
  40. }
  41. /*********************************************************
  42. * For Win32 emulation - automatically add the tick functions
  43. * the user would normally have to provide for bare metal.
  44. *********************************************************/
  45. #if defined(WIN32)
  46. // Win32 nasty stuff - we have conflicting definitions for Red, Green & Blue
  47. #ifndef _WIN32_WINNT
  48. #define _WIN32_WINNT 0x0501 // Windows XP and up
  49. #endif
  50. #undef Red
  51. #undef Green
  52. #undef Blue
  53. #define WIN32_LEAN_AND_MEAN
  54. #include <windows.h>
  55. #undef WIN32_LEAN_AND_MEAN
  56. #define Blue HTML2COLOR(0x0000FF)
  57. #define Red HTML2COLOR(0xFF0000)
  58. #define Green HTML2COLOR(0x008000)
  59. #include <stdio.h>
  60. systemticks_t gfxSystemTicks(void) { return GetTickCount(); }
  61. systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; }
  62. #endif
  63. /*********************************************************
  64. * Exit everything functions
  65. *********************************************************/
  66. void gfxHalt(const char *msg) {
  67. #if defined(WIN32)
  68. fprintf(stderr, "%s\n", msg);
  69. ExitProcess(1);
  70. #else
  71. volatile uint32_t dummy;
  72. (void) msg;
  73. while(1)
  74. dummy++;
  75. #endif
  76. }
  77. void gfxExit(void) {
  78. #if defined(WIN32)
  79. ExitProcess(0);
  80. #else
  81. volatile uint32_t dummy;
  82. while(1)
  83. dummy++;
  84. #endif
  85. }
  86. #endif /* GFX_USE_OS_RAW32 */