Skip to content

Commit 6a1d169

Browse files
committed
CM: Rename public interfaces to start with 'cm_'
1 parent 8ab7d32 commit 6a1d169

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

include/cm/cm.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111
#include <types.h>
1212
#include <stdarg.h>
1313

14-
15-
#define HALT() for (;;)
16-
14+
#define INVALID_HANDLE (-1)
15+
#define HALT() for (;;)
1716

1817
INT snprintf (CHAR* dest, size_t size, const CHAR* fmt, ...);
1918
INT vsnprintf (CHAR* dest, size_t size, const CHAR* fmt, va_list l);
2019

21-
2220
/***************************************************************************************************
2321
* Halts thread for 'ms' miliseconds
2422
*
2523
* @return Nothing
2624
**************************************************************************************************/
27-
void delay (UINT ms);
25+
void cm_delay (UINT ms);

include/cm/syscall.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,68 +17,68 @@
1717
#endif
1818

1919
S32 syscall (OSIF_SYSCALLS fn, U32 arg1, U32 arg2, U32 arg3, U32 arg4, U32 arg5);
20-
INT os_thread_create (void (*startLocation)(), bool isKernelMode);
21-
INT os_process_create (void* startLocation, SIZE binaryLengthBytes, bool isKernelMode);
22-
UINT os_get_tick_period_us();
23-
bool os_process_is_yield_requested();
24-
bool os_process_is_child_exited (UINT* exitCode);
20+
INT cm_thread_create (void (*startLocation)(), bool isKernelMode);
21+
INT cm_process_create (void* startLocation, SIZE binaryLengthBytes, bool isKernelMode);
22+
UINT cm_get_tick_period_us();
23+
bool cm_process_is_yield_requested();
24+
bool cm_process_is_child_exited (UINT* exitCode);
2525

26-
static inline UINT os_tickcount_to_microsec(UINT tick)
26+
static inline UINT cm_tickcount_to_microsec(UINT tick)
2727
{
28-
return ((tick)*os_get_tick_period_us());
28+
return ((tick)*cm_get_tick_period_us());
2929
}
3030

31-
static inline void os_yield()
31+
static inline void cm_process_yield()
3232
{
3333
syscall (OSIF_SYSCALL_YIELD_PROCESS, 0, 0, 0, 0, 0);
3434
}
3535

36-
static inline void os_process_kill(UINT code)
36+
static inline void cm_process_kill(UINT code)
3737
{
3838
syscall (OSIF_SYSCALL_KILL_PROCESS, code, 0, 0, 0, 0);
3939
}
4040

41-
static inline void os_putstr (char* text)
41+
static inline void cm_putstr (char* text)
4242
{
4343
syscall (OSIF_SYSCALL_CONSOLE_WRITELN, (PTR)text, 0, 0, 0, 0);
4444
}
4545

46-
static inline U32 os_process_get_pid()
46+
static inline U32 cm_process_get_pid()
4747
{
4848
return (U32)syscall (OSIF_SYSCALL_PROCESS_GETPID, 0, 0, 0, 0, 0);
4949
}
5050

51-
static inline U32 os_get_tickcount()
51+
static inline U32 cm_get_tickcount()
5252
{
5353
return (U32)syscall (OSIF_SYSCALL_TIMER_GET_TICKCOUNT, 0, 0, 0, 0, 0);
5454
}
5555

56-
static inline Handle os_window_create (const char* title)
56+
static inline Handle cm_window_create (const char* title)
5757
{
5858
return (Handle)syscall (OSIF_SYSCALL_WINDOW_CREATE, (PTR)title, 0, 0, 0, 0);
5959
}
6060

61-
static inline U32 os_window_destory (Handle h)
61+
static inline U32 cm_window_destory (Handle h)
6262
{
6363
return (U32)syscall (OSIF_SYSCALL_WINDOW_DESTORY, (U32)h, 0, 0, 0, 0);
6464
}
6565

66-
static inline void* os_process_get_datamem_start()
66+
static inline void* cm_process_get_datamem_start()
6767
{
6868
return (void*)syscall (OSIF_SYSCALL_PROCESS_GET_DATAMEM_START, 0, 0, 0, 0, 0);
6969
}
7070

71-
static inline void* os_window_flush_graphics()
71+
static inline void* cm_window_flush_graphics()
7272
{
7373
return (void*)syscall (OSIF_SYSCALL_WINDOW_FLUSH_GRAPHICS, 0, 0, 0, 0, 0);
7474
}
7575

76-
static inline bool os_window_getFB (Handle h, OSIF_WindowFrameBufferInfo* wfb)
76+
static inline bool cm_window_getFB (Handle h, OSIF_WindowFrameBufferInfo* wfb)
7777
{
7878
return syscall (OSIF_SYSCALL_WINDOW_GET_WINDOW_FB, (U32)h, (PTR)wfb, 0, 0, 0);
7979
}
8080

81-
static inline bool os_process_pop_event (OSIF_ProcessEvent* e)
81+
static inline bool cm_process_pop_event (OSIF_ProcessEvent* e)
8282
{
8383
return syscall (OSIF_SYSCALL_POP_PROCESS_EVENT, (PTR)e, 0, 0, 0, 0);
8484
}

src/apps/gui0.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
#include <types.h>
33
#include <cm.h>
44
#include <graphics.h>
5+
#include <debug.h>
56

67
void thread0();
78
void thread1();
89
void thread2();
910

1011
static OSIF_WindowFrameBufferInfo createWindow (const char* const title)
1112
{
12-
Handle h = os_window_create (title);
13+
Handle h = cm_window_create (title);
1314
if (h == INVALID_HANDLE) {
1415
ERROR ("Window creation failed");
1516
HALT();
1617
}
1718

1819
OSIF_WindowFrameBufferInfo fbi;
19-
if (!os_window_getFB (h, &fbi)) {
20+
if (!cm_window_getFB (h, &fbi)) {
2021
ERROR ("Window creation failed");
2122
HALT();
2223
}
@@ -26,14 +27,14 @@ static OSIF_WindowFrameBufferInfo createWindow (const char* const title)
2627

2728
void proc_main()
2829
{
29-
os_window_flush_graphics();
30-
os_thread_create (&thread1, false);
31-
os_thread_create (&thread2, false);
32-
os_thread_create (&thread0, false);
30+
cm_window_flush_graphics();
31+
cm_thread_create (&thread1, false);
32+
cm_thread_create (&thread2, false);
33+
cm_thread_create (&thread0, false);
3334

3435
while (1) {
35-
if (os_process_is_yield_requested()) {
36-
os_yield();
36+
if (cm_process_is_yield_requested()) {
37+
cm_process_yield();
3738
}
3839
}
3940
}
@@ -53,8 +54,8 @@ void thread0()
5354
graphics_rect (&fbi, (UINT)x, 0, (UINT)width, fbi.height_px, color);
5455
x += width + 3;
5556

56-
os_window_flush_graphics();
57-
delay (500);
57+
cm_window_flush_graphics();
58+
cm_delay (500);
5859
}
5960
}
6061

@@ -77,8 +78,8 @@ void thread1()
7778
graphics_putpixel (&fbi, x, y, color);
7879
}
7980
}
80-
os_window_flush_graphics();
81-
delay (100);
81+
cm_window_flush_graphics();
82+
cm_delay (100);
8283
}
8384
}
8485

@@ -101,7 +102,7 @@ void thread2()
101102
graphics_putpixel (&fbi, x, y, color);
102103
}
103104
}
104-
os_window_flush_graphics();
105-
delay (80);
105+
cm_window_flush_graphics();
106+
cm_delay (80);
106107
}
107108
}

src/cm/cm.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
#include <types.h>
88
#include <cm/cm.h>
99
#include <cm/syscall.h>
10+
#include <cm/debug.h>
1011

11-
#define OS_MICRODEC_TO_TICK_COUNT(us) ((us) / os_get_tick_period_us())
12+
#define cm_MICRODEC_TO_TICK_COUNT(us) ((us) / cm_get_tick_period_us())
1213

1314
void event_handler_NDU_()
1415
{
1516
volatile OSIF_ProcessEvent e = { 0 };
16-
os_process_pop_event ((OSIF_ProcessEvent*)&e);
17+
cm_process_pop_event ((OSIF_ProcessEvent*)&e);
1718
switch (e.event) {
1819
case OSIF_PROCESS_EVENT_PROCCESS_YIELD_REQ:
19-
os_yield();
20+
cm_process_yield();
2021
break;
2122
case OSIF_PROCESS_EVENT_PROCCESS_CHILD_KILLED:
2223
INFO ("Child exitted with code: %x", e.data);
@@ -26,14 +27,14 @@ void event_handler_NDU_()
2627
}
2728
}
2829

29-
void delay (UINT ms)
30+
void cm_delay (UINT ms)
3031
{
3132
UINT us = ms * 1000;
3233

33-
U32 start_tick = os_get_tickcount();
34-
U32 end_tick = start_tick + OS_MICRODEC_TO_TICK_COUNT (us);
34+
U32 start_tick = cm_get_tickcount();
35+
U32 end_tick = start_tick + cm_MICRODEC_TO_TICK_COUNT (us);
3536

36-
while (os_get_tickcount() < end_tick) {
37+
while (cm_get_tickcount() < end_tick) {
3738
event_handler_NDU_();
3839
}
3940
}

src/cm/syscalls.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ S32 syscall (OSIF_SYSCALLS fn, U32 arg1, U32 arg2, U32 arg3, U32 arg4, U32 arg5)
3030
return retval;
3131
}
3232

33-
INT os_process_create (void* startLocation, SIZE binaryLengthBytes, bool isKernelMode)
33+
INT cm_process_create (void* startLocation, SIZE binaryLengthBytes, bool isKernelMode)
3434
{
3535
KProcessFlags flags = PROCESS_FLAGS_NONE;
3636
if (isKernelMode) {
@@ -41,7 +41,7 @@ INT os_process_create (void* startLocation, SIZE binaryLengthBytes, bool isKerne
4141
0, 0);
4242
}
4343

44-
INT os_thread_create (void (*startLocation)(), bool isKernelMode)
44+
INT cm_thread_create (void (*startLocation)(), bool isKernelMode)
4545
{
4646
KProcessFlags flags = PROCESS_FLAGS_THREAD;
4747
if (isKernelMode) {
@@ -50,14 +50,14 @@ INT os_thread_create (void (*startLocation)(), bool isKernelMode)
5050
return syscall (OSIF_SYSCALL_CREATE_PROCESS, (U32)startLocation, 0, (U32)flags, 0, 0);
5151
}
5252

53-
bool os_process_is_yield_requested()
53+
bool cm_process_is_yield_requested()
5454
{
5555
volatile OSIF_ProcessEvent e = { 0 };
56-
os_process_pop_event ((OSIF_ProcessEvent*)&e);
56+
cm_process_pop_event ((OSIF_ProcessEvent*)&e);
5757
return (e.event == OSIF_PROCESS_EVENT_PROCCESS_YIELD_REQ);
5858
}
5959

60-
UINT os_get_tick_period_us()
60+
UINT cm_get_tick_period_us()
6161
{
6262
return CONFIG_TICK_PERIOD_MICROSEC;
6363
}

0 commit comments

Comments
 (0)