Skip to content

Commit a08bfeb

Browse files
nashifcarlescufi
authored andcommitted
syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
1 parent ee9f278 commit a08bfeb

File tree

82 files changed

+651
-651
lines changed

Some content is hidden

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

82 files changed

+651
-651
lines changed

doc/kernel/drivers/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ implementation of both the subsystem API and the specific APIs:
239239
240240
int z_vrfy_specific_from_user(const struct device *dev, int bar)
241241
{
242-
Z_OOPS(K_SYSCALL_SPECIFIC_DRIVER(dev, K_OBJ_DRIVER_GENERIC, &api));
242+
K_OOPS(K_SYSCALL_SPECIFIC_DRIVER(dev, K_OBJ_DRIVER_GENERIC, &api));
243243
return z_impl_specific_do_that(dev, bar)
244244
}
245245

doc/kernel/usermode/syscalls.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Several macros exist to validate arguments:
331331
API structure.
332332

333333
If any check fails, the macros will return a nonzero value. The macro
334-
:c:macro:`Z_OOPS()` can be used to induce a kernel oops which will kill the
334+
:c:macro:`K_OOPS()` can be used to induce a kernel oops which will kill the
335335
calling thread. This is done instead of returning some error condition to
336336
keep the APIs the same when calling from supervisor mode.
337337

@@ -357,7 +357,7 @@ For example:
357357
358358
static int z_vrfy_k_sem_take(struct k_sem *sem, int32_t timeout)
359359
{
360-
Z_OOPS(K_SYSCALL_OBJ(sem, K_OBJ_SEM));
360+
K_OOPS(K_SYSCALL_OBJ(sem, K_OBJ_SEM));
361361
return z_impl_k_sem_take(sem, timeout);
362362
}
363363
#include <syscalls/k_sem_take_mrsh.c>
@@ -397,7 +397,7 @@ for some integral value:
397397
int ret;
398398
399399
ret = z_impl_some_syscall(&local_out_param);
400-
Z_OOPS(k_usermode_to_copy(out_param, &local_out_param, sizeof(*out_param)));
400+
K_OOPS(k_usermode_to_copy(out_param, &local_out_param, sizeof(*out_param)));
401401
return ret;
402402
}
403403
@@ -411,7 +411,7 @@ It might be tempting to do something more concise:
411411
412412
int z_vrfy_some_syscall(int *out_param)
413413
{
414-
Z_OOPS(K_SYSCALL_MEMORY_WRITE(out_param, sizeof(*out_param)));
414+
K_OOPS(K_SYSCALL_MEMORY_WRITE(out_param, sizeof(*out_param)));
415415
return z_impl_some_syscall(out_param);
416416
}
417417
@@ -433,9 +433,9 @@ bytes processed. This too should use a stack copy:
433433
size_t size;
434434
int ret;
435435
436-
Z_OOPS(k_usermode_from_copy(&size, size_ptr, sizeof(size));
436+
K_OOPS(k_usermode_from_copy(&size, size_ptr, sizeof(size));
437437
ret = z_impl_in_out_syscall(&size);
438-
Z_OOPS(k_usermode_to_copy(size_ptr, &size, sizeof(size)));
438+
K_OOPS(k_usermode_to_copy(size_ptr, &size, sizeof(size)));
439439
return ret;
440440
}
441441
@@ -461,11 +461,11 @@ be copied. Typically this is done by allocating copies on the stack:
461461
struct bar bar_right_copy;
462462
struct bar bar_left_copy;
463463
464-
Z_OOPS(k_usermode_from_copy(&foo_copy, foo, sizeof(*foo)));
465-
Z_OOPS(k_usermode_from_copy(&bar_right_copy, foo_copy.bar_right,
464+
K_OOPS(k_usermode_from_copy(&foo_copy, foo, sizeof(*foo)));
465+
K_OOPS(k_usermode_from_copy(&bar_right_copy, foo_copy.bar_right,
466466
sizeof(struct bar)));
467467
foo_copy.bar_right = &bar_right_copy;
468-
Z_OOPS(k_usermode_from_copy(&bar_left_copy, foo_copy.bar_left,
468+
K_OOPS(k_usermode_from_copy(&bar_left_copy, foo_copy.bar_left,
469469
sizeof(struct bar)));
470470
foo_copy.bar_left = &bar_left_copy;
471471
@@ -478,7 +478,7 @@ memory from the caller's resource pool via :c:func:`z_thread_malloc()`. This
478478
should always be considered last resort. Functional safety programming
479479
guidelines heavily discourage usage of heap and the fact that a resource pool is
480480
used must be clearly documented. Any issues with allocation must be
481-
reported, to a caller, with returning the ``-ENOMEM`` . The ``Z_OOPS()``
481+
reported, to a caller, with returning the ``-ENOMEM`` . The ``K_OOPS()``
482482
should never be used to verify if resource allocation has been successful.
483483

484484
.. code-block:: c
@@ -500,7 +500,7 @@ should never be used to verify if resource allocation has been successful.
500500
size_t bar_list_bytes;
501501
502502
/* Safely copy foo into foo_copy */
503-
Z_OOPS(k_usermode_from_copy(&foo_copy, foo, sizeof(*foo)));
503+
K_OOPS(k_usermode_from_copy(&foo_copy, foo, sizeof(*foo)));
504504
505505
/* Bounds check the count member, in the copy we made */
506506
if (foo_copy.count > 32) {
@@ -514,7 +514,7 @@ should never be used to verify if resource allocation has been successful.
514514
if (bar_list_copy == NULL) {
515515
return -ENOMEM;
516516
}
517-
Z_OOPS(k_usermode_from_copy(bar_list_copy, foo_copy.bar_list,
517+
K_OOPS(k_usermode_from_copy(bar_list_copy, foo_copy.bar_list,
518518
bar_list_bytes));
519519
foo_copy.bar_list = bar_list_copy;
520520
@@ -549,7 +549,7 @@ The following constraints need to be met:
549549
550550
int z_vrfy_get_data_from_kernel(void *buf, size_t size)
551551
{
552-
Z_OOPS(K_SYSCALL_MEMORY_WRITE(buf, size));
552+
K_OOPS(K_SYSCALL_MEMORY_WRITE(buf, size));
553553
return z_impl_get_data_from_kernel(buf, size);
554554
}
555555
@@ -558,16 +558,16 @@ Verification Return Value Policies
558558

559559
When verifying system calls, it's important to note which kinds of verification
560560
failures should propagate a return value to the caller, and which should
561-
simply invoke :c:macro:`Z_OOPS()` which kills the calling thread. The current
561+
simply invoke :c:macro:`K_OOPS()` which kills the calling thread. The current
562562
conventions are as follows:
563563

564564
#. For system calls that are defined but not compiled, invocations of these
565565
missing system calls are routed to :c:func:`handler_no_syscall()` which
566-
invokes :c:macro:`Z_OOPS()`.
566+
invokes :c:macro:`K_OOPS()`.
567567

568568
#. Any invalid access to memory found by the set of ``K_SYSCALL_MEMORY`` APIs,
569569
:c:func:`k_usermode_from_copy()`, :c:func:`k_usermode_to_copy()`
570-
should trigger a :c:macro:`Z_OOPS`. This happens when the caller doesn't have
570+
should trigger a :c:macro:`K_OOPS`. This happens when the caller doesn't have
571571
appropriate permissions on the memory buffer or some size calculation
572572
overflowed.
573573

@@ -576,7 +576,7 @@ conventions are as follows:
576576
manually using :c:func:`k_object_validate()`. These can fail for a variety
577577
of reasons: missing driver API, bad kernel object pointer, wrong kernel
578578
object type, or improper initialization state. These issues should always
579-
invoke :c:macro:`Z_OOPS()`.
579+
invoke :c:macro:`K_OOPS()`.
580580

581581
#. Any error resulting from a failed memory heap allocation, often from
582582
invoking :c:func:`z_thread_malloc()`, should propagate ``-ENOMEM`` to the
@@ -594,7 +594,7 @@ conventions are as follows:
594594
be registered from user mode. APIs which simply install callbacks shall not
595595
be exposed as system calls. Some driver subsystem APIs may take optional
596596
function callback pointers. User mode verification functions for these APIs
597-
must enforce that these are NULL and should invoke :c:macro:`Z_OOPS()` if
597+
must enforce that these are NULL and should invoke :c:macro:`K_OOPS()` if
598598
not.
599599

600600
#. Some parameter checks are enforced only from user mode. These should be
@@ -608,14 +608,14 @@ There are some known exceptions to these policies currently in Zephyr:
608608
initialization bit pulls double-duty to indicate whether a thread is
609609
running, cleared upon exit. See #23030.
610610

611-
* :c:func:`k_thread_create()` invokes :c:macro:`Z_OOPS()` for parameter
611+
* :c:func:`k_thread_create()` invokes :c:macro:`K_OOPS()` for parameter
612612
checks, due to a great deal of existing code ignoring the return value.
613613
This will also be addressed by #23030.
614614

615-
* :c:func:`k_thread_abort()` invokes :c:macro:`Z_OOPS()` if an essential
615+
* :c:func:`k_thread_abort()` invokes :c:macro:`K_OOPS()` if an essential
616616
thread is aborted, as the function has no return value.
617617

618-
* Various system calls related to logging invoke :c:macro:`Z_OOPS()`
618+
* Various system calls related to logging invoke :c:macro:`K_OOPS()`
619619
when bad parameters are passed in as they do not propagate errors.
620620

621621
Configuration Options
@@ -635,7 +635,7 @@ Helper macros for creating system call verification functions are provided in
635635
* :c:macro:`K_SYSCALL_OBJ()`
636636
* :c:macro:`K_SYSCALL_OBJ_INIT()`
637637
* :c:macro:`K_SYSCALL_OBJ_NEVER_INIT()`
638-
* :c:macro:`Z_OOPS()`
638+
* :c:macro:`K_OOPS()`
639639
* :c:macro:`K_SYSCALL_MEMORY_READ()`
640640
* :c:macro:`K_SYSCALL_MEMORY_WRITE()`
641641
* :c:macro:`K_SYSCALL_MEMORY_ARRAY_READ()`

drivers/adc/adc_handlers.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ static inline int z_vrfy_adc_channel_setup(const struct device *dev,
1313
{
1414
struct adc_channel_cfg channel_cfg;
1515

16-
Z_OOPS(K_SYSCALL_DRIVER_ADC(dev, channel_setup));
17-
Z_OOPS(k_usermode_from_copy(&channel_cfg,
16+
K_OOPS(K_SYSCALL_DRIVER_ADC(dev, channel_setup));
17+
K_OOPS(k_usermode_from_copy(&channel_cfg,
1818
(struct adc_channel_cfg *)user_channel_cfg,
1919
sizeof(struct adc_channel_cfg)));
2020

@@ -55,12 +55,12 @@ static inline int z_vrfy_adc_read(const struct device *dev,
5555
struct adc_sequence sequence;
5656
struct adc_sequence_options options;
5757

58-
Z_OOPS(K_SYSCALL_DRIVER_ADC(dev, read));
59-
Z_OOPS(K_SYSCALL_VERIFY_MSG(copy_sequence(&sequence, &options,
58+
K_OOPS(K_SYSCALL_DRIVER_ADC(dev, read));
59+
K_OOPS(K_SYSCALL_VERIFY_MSG(copy_sequence(&sequence, &options,
6060
(struct adc_sequence *)user_sequence),
6161
"invalid ADC sequence"));
6262
if (sequence.options != NULL) {
63-
Z_OOPS(K_SYSCALL_VERIFY_MSG(sequence.options->callback == NULL,
63+
K_OOPS(K_SYSCALL_VERIFY_MSG(sequence.options->callback == NULL,
6464
"ADC sequence callbacks forbidden from user mode"));
6565
}
6666

@@ -76,15 +76,15 @@ static inline int z_vrfy_adc_read_async(const struct device *dev,
7676
struct adc_sequence sequence;
7777
struct adc_sequence_options options;
7878

79-
Z_OOPS(K_SYSCALL_DRIVER_ADC(dev, read_async));
80-
Z_OOPS(K_SYSCALL_VERIFY_MSG(copy_sequence(&sequence, &options,
79+
K_OOPS(K_SYSCALL_DRIVER_ADC(dev, read_async));
80+
K_OOPS(K_SYSCALL_VERIFY_MSG(copy_sequence(&sequence, &options,
8181
(struct adc_sequence *)user_sequence),
8282
"invalid ADC sequence"));
8383
if (sequence.options != NULL) {
84-
Z_OOPS(K_SYSCALL_VERIFY_MSG(sequence.options->callback == NULL,
84+
K_OOPS(K_SYSCALL_VERIFY_MSG(sequence.options->callback == NULL,
8585
"ADC sequence callbacks forbidden from user mode"));
8686
}
87-
Z_OOPS(K_SYSCALL_OBJ(async, K_OBJ_POLL_SIGNAL));
87+
K_OOPS(K_SYSCALL_OBJ(async, K_OBJ_POLL_SIGNAL));
8888

8989
return z_impl_adc_read_async((const struct device *)dev, &sequence,
9090
(struct k_poll_signal *)async);

drivers/auxdisplay/auxdisplay_handlers.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@
99

1010
static inline int z_vrfy_auxdisplay_display_on(const struct device *dev)
1111
{
12-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
12+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
1313
return z_impl_auxdisplay_display_on(dev);
1414
}
1515
#include <syscalls/auxdisplay_display_on_mrsh.c>
1616

1717
static inline int z_vrfy_auxdisplay_display_off(const struct device *dev)
1818
{
19-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
19+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
2020
return z_impl_auxdisplay_display_off(dev);
2121
}
2222
#include <syscalls/auxdisplay_display_off_mrsh.c>
2323

2424
static inline int z_vrfy_auxdisplay_cursor_set_enabled(const struct device *dev, bool enabled)
2525
{
26-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
26+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
2727
return z_impl_auxdisplay_cursor_set_enabled(dev, enabled);
2828
}
2929
#include <syscalls/auxdisplay_cursor_set_enabled_mrsh.c>
3030

3131
static inline int z_vrfy_auxdisplay_position_blinking_set_enabled(const struct device *dev,
3232
bool enabled)
3333
{
34-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
34+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
3535
return z_impl_auxdisplay_position_blinking_set_enabled(dev, enabled);
3636
}
3737
#include <syscalls/auxdisplay_position_blinking_set_enabled_mrsh.c>
3838

3939
static inline int z_vrfy_auxdisplay_cursor_shift_set(const struct device *dev, uint8_t direction,
4040
bool display_shift)
4141
{
42-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
42+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
4343
return z_impl_auxdisplay_cursor_shift_set(dev, direction, display_shift);
4444
}
4545
#include <syscalls/auxdisplay_cursor_shift_set_mrsh.c>
@@ -48,15 +48,15 @@ static inline int z_vrfy_auxdisplay_cursor_position_set(const struct device *dev
4848
enum auxdisplay_position type,
4949
int16_t x, int16_t y)
5050
{
51-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
51+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
5252
return z_impl_auxdisplay_cursor_position_set(dev, type, x, y);
5353
}
5454
#include <syscalls/auxdisplay_cursor_position_set_mrsh.c>
5555

5656
static inline int z_vrfy_auxdisplay_cursor_position_get(const struct device *dev, int16_t *x,
5757
int16_t *y)
5858
{
59-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
59+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
6060
return z_impl_auxdisplay_cursor_position_get(dev, x, y);
6161
}
6262
#include <syscalls/auxdisplay_cursor_position_get_mrsh.c>
@@ -65,93 +65,93 @@ static inline int z_vrfy_auxdisplay_display_position_set(const struct device *de
6565
enum auxdisplay_position type,
6666
int16_t x, int16_t y)
6767
{
68-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
68+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
6969
return z_impl_auxdisplay_display_position_set(dev, type, x, y);
7070
}
7171
#include <syscalls/auxdisplay_display_position_set_mrsh.c>
7272

7373
static inline int z_vrfy_auxdisplay_display_position_get(const struct device *dev, int16_t *x,
7474
int16_t *y)
7575
{
76-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
76+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
7777
return z_impl_auxdisplay_display_position_get(dev, x, y);
7878
}
7979
#include <syscalls/auxdisplay_display_position_get_mrsh.c>
8080

8181
static inline int z_vrfy_auxdisplay_capabilities_get(const struct device *dev,
8282
struct auxdisplay_capabilities *capabilities)
8383
{
84-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
84+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
8585
return z_impl_auxdisplay_capabilities_get(dev, capabilities);
8686
}
8787
#include <syscalls/auxdisplay_capabilities_get_mrsh.c>
8888

8989
static inline int z_vrfy_auxdisplay_clear(const struct device *dev)
9090
{
91-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
91+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
9292
return z_impl_auxdisplay_clear(dev);
9393
}
9494
#include <syscalls/auxdisplay_clear_mrsh.c>
9595

9696
static inline int z_vrfy_auxdisplay_brightness_get(const struct device *dev,
9797
uint8_t *brightness)
9898
{
99-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
99+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
100100
return z_impl_auxdisplay_brightness_get(dev, brightness);
101101
}
102102
#include <syscalls/auxdisplay_brightness_get_mrsh.c>
103103

104104
static inline int z_vrfy_auxdisplay_brightness_set(const struct device *dev,
105105
uint8_t brightness)
106106
{
107-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
107+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
108108
return z_impl_auxdisplay_brightness_set(dev, brightness);
109109
}
110110
#include <syscalls/auxdisplay_brightness_set_mrsh.c>
111111

112112
static inline int z_vrfy_auxdisplay_backlight_get(const struct device *dev,
113113
uint8_t *backlight)
114114
{
115-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
115+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
116116
return z_impl_auxdisplay_backlight_get(dev, backlight);
117117
}
118118
#include <syscalls/auxdisplay_backlight_get_mrsh.c>
119119

120120
static inline int z_vrfy_auxdisplay_backlight_set(const struct device *dev,
121121
uint8_t backlight)
122122
{
123-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
123+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
124124
return z_impl_auxdisplay_backlight_set(dev, backlight);
125125
}
126126
#include <syscalls/auxdisplay_backlight_set_mrsh.c>
127127

128128
static inline int z_vrfy_auxdisplay_is_busy(const struct device *dev)
129129
{
130-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
130+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
131131
return z_impl_auxdisplay_is_busy(dev);
132132
}
133133
#include <syscalls/auxdisplay_is_busy_mrsh.c>
134134

135135
static inline int z_vrfy_auxdisplay_custom_character_set(const struct device *dev,
136136
struct auxdisplay_character *character)
137137
{
138-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
138+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
139139
return z_impl_auxdisplay_custom_character_set(dev, character);
140140
}
141141
#include <syscalls/auxdisplay_custom_character_set_mrsh.c>
142142

143143
static inline int z_vrfy_auxdisplay_write(const struct device *dev, const uint8_t *data,
144144
uint16_t len)
145145
{
146-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
146+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
147147
return z_impl_auxdisplay_write(dev, data, len);
148148
}
149149
#include <syscalls/auxdisplay_write_mrsh.c>
150150

151151
static inline int z_vrfy_auxdisplay_custom_command(const struct device *dev,
152152
struct auxdisplay_custom_data *data)
153153
{
154-
Z_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
154+
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_AUXDISPLAY));
155155
return z_impl_auxdisplay_custom_command(dev, data);
156156
}
157157
#include <syscalls/auxdisplay_custom_command_mrsh.c>

0 commit comments

Comments
 (0)