Skip to content

Commit 1ee3dbf

Browse files
bradjcppannuto
authored andcommitted
libtock: do not export more syscalls
1 parent ce40faf commit 1ee3dbf

File tree

110 files changed

+288
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+288
-86
lines changed

libtock/display/screen.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdlib.h>
22

33
#include "screen.h"
4+
#include "syscalls/screen_syscalls.h"
45

56
static void screen_callback_done(int status,
67
__attribute__ ((unused)) int data1,
@@ -26,6 +27,9 @@ static void screen_callback_rotation(int status,
2627
cb(tock_status_to_returncode(status), (libtock_screen_rotation_t) data1);
2728
}
2829

30+
bool libtock_screen_exists(void) {
31+
return libtock_screen_driver_exists();
32+
}
2933

3034
statuscode_t libtock_screen_buffer_init(size_t len, uint8_t** buffer) {
3135
if (*buffer != NULL) return TOCK_STATUSCODE_ALREADY;

libtock/display/screen.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#pragma once
22

33
#include "../tock.h"
4-
#include "syscalls/screen_syscalls.h"
54

65
#ifdef __cplusplus
76
extern "C" {
87
#endif
98

10-
#define DRIVER_NUM_SCREEN 0x90001
11-
129
// Supported pixel formats.
1310
typedef enum {
1411
MONO =0,
@@ -42,6 +39,8 @@ typedef void (*libtock_screen_callback_format)(returncode_t, libtock_screen_form
4239
// The callback includes the rotation angle as an int.
4340
typedef void (*libtock_screen_callback_rotation)(returncode_t, libtock_screen_rotation_t);
4441

42+
// Check if the screen driver exists.
43+
bool libtock_screen_exists(void);
4544

4645
// INIT
4746

libtock/display/syscalls/screen_syscalls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "screen_syscalls.h"
22

3-
bool libtock_screen_exists(void) {
3+
bool libtock_screen_driver_exists(void) {
44
return driver_exists(DRIVER_NUM_SCREEN);
55
}
66

libtock/display/syscalls/screen_syscalls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern "C" {
99
#define DRIVER_NUM_SCREEN 0x90001
1010

1111
// Check if the screen driver exists.
12-
bool libtock_screen_exists(void);
12+
bool libtock_screen_driver_exists(void);
1313

1414
// Set the upcall for screen upcalls.
1515
returncode_t libtock_screen_set_upcall(subscribe_upcall cb, void* opaque);

libtock/display/syscalls/text_screen_syscalls.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "text_screen_syscalls.h"
22

3+
bool libtock_text_screen_driver_exists(void) {
4+
return driver_exists(DRIVER_NUM_TEXT_SCREEN);
5+
}
6+
37
returncode_t libtock_text_screen_set_upcall(subscribe_upcall callback, void* opaque) {
48
subscribe_return_t sval = subscribe(DRIVER_NUM_TEXT_SCREEN, 0, callback, opaque);
59
return tock_subscribe_return_to_returncode(sval);

libtock/display/syscalls/text_screen_syscalls.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ extern "C" {
88

99
#define DRIVER_NUM_TEXT_SCREEN 0x90003
1010

11+
// Check if the text screen driver exists.
12+
bool libtock_text_screen_driver_exists(void);
13+
1114
returncode_t libtock_text_screen_set_upcall(subscribe_upcall callback, void* opaque);
1215

1316
returncode_t libtock_text_screen_set_readonly_allow(const uint8_t* ptr, uint32_t size);

libtock/display/text_screen.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "text_screen.h"
2+
#include "syscalls/text_screen_syscalls.h"
23

34
static void text_screen_callback(int status,
45
__attribute__ ((unused)) int data1,
@@ -16,6 +17,10 @@ static void text_screen_callback_size(int status,
1617
cb(tock_status_to_returncode(status), (uint32_t) data1, (uint32_t) data2);
1718
}
1819

20+
bool libtock_text_screen_exists(void) {
21+
return libtock_text_screen_driver_exists();
22+
}
23+
1924
returncode_t libtock_text_screen_display_on(libtock_text_screen_callback_done cb) {
2025
returncode_t err;
2126

libtock/display/text_screen.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#pragma once
22

33
#include "../tock.h"
4-
#include "syscalls/text_screen_syscalls.h"
54

65
#ifdef __cplusplus
76
extern "C" {
87
#endif
98

10-
#define DRIVER_NUM_TEXT_SCREEN 0x90003
11-
129
// Callback when an operation has completed.
1310
//
1411
// This callback is used for several operations, but is generic as it only
@@ -22,6 +19,9 @@ typedef void (*libtock_text_screen_callback_done)(returncode_t);
2219
// - `arg3` (`uint32_t`): Height of display.
2320
typedef void (*libtock_text_screen_callback_size)(returncode_t, uint32_t, uint32_t);
2421

22+
// Check if the text screen driver exists.
23+
bool libtock_text_screen_exists(void);
24+
2525
returncode_t libtock_text_screen_display_on(libtock_text_screen_callback_done cb);
2626

2727
returncode_t libtock_text_screen_display_off(libtock_text_screen_callback_done cb);

libtock/interface/button.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#include "button.h"
2+
#include "syscalls/button_syscalls.h"
3+
4+
bool libtock_button_exists(void) {
5+
return libtock_button_driver_exists();
6+
}
27

38
returncode_t libtock_button_count(int* count) {
49
return libtock_button_command_count(count);

libtock/interface/button.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "../tock.h"
4-
#include "syscalls/button_syscalls.h"
54

65
#ifdef __cplusplus
76
extern "C" {
@@ -14,6 +13,9 @@ extern "C" {
1413
// - `arg3` (`bool`): True if pressed, false otherwise.
1514
typedef void (*libtock_button_callback)(returncode_t, int, bool);
1615

16+
// Check if the driver exists.
17+
bool libtock_button_exists(void);
18+
1719
// Read the current button state into `button_value`.
1820
//
1921
// ## Arguments

0 commit comments

Comments
 (0)