-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[7/10] libc, sched: Resolve FDPIC descriptors at module callback entry points #20130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,9 @@ | |
|
|
||
| #include <nuttx/wqueue.h> | ||
| #include <nuttx/sched.h> | ||
| #ifdef CONFIG_FDPIC | ||
| # include <nuttx/fdpic.h> | ||
| #endif | ||
|
|
||
| /**************************************************************************** | ||
| * Pre-processor Definitions | ||
|
|
@@ -67,7 +70,14 @@ struct sigwork_s | |
| { | ||
| struct work_s work; /* Work queue structure */ | ||
| union sigval value; /* Data passed with notification */ | ||
| #ifdef CONFIG_FDPIC | ||
| struct fdpic_desc_s desc; /* Notification function, and the data base | ||
| * of a module callback or zero. The base is | ||
| * captured at registration and installed | ||
| * around the call on the worker thread. */ | ||
| #else | ||
| sigev_notify_function_t func; /* Notification function */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why need define desc at line 74? I suppose that func should point to fdpic_desc_s in fdpic case.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the firmware and the built-in applications are not FDPIC, so their |
||
| #endif | ||
| }; | ||
|
|
||
| #ifdef __cplusplus | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,10 @@ _sa_handler_t signal(int signo, _sa_handler_t func) | |
|
|
||
| DEBUGASSERT(func != SIG_ERR && func != SIG_HOLD); | ||
|
|
||
| /* Not resolved here. nxsig_action() resolves the handler, which covers | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the comment? |
||
| * a module calling sigaction() directly as well. | ||
| */ | ||
|
|
||
| /* Initialize the sigaction structure */ | ||
|
|
||
| act.sa_handler = func; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,10 @@ | |
|
|
||
| #include <nuttx/signal.h> | ||
|
|
||
| #ifdef CONFIG_FDPIC | ||
| # include <nuttx/fdpic.h> | ||
| #endif | ||
|
|
||
| #include "sched/sched.h" | ||
| #include "signal/signal.h" | ||
|
|
||
|
|
@@ -70,7 +74,23 @@ static void nxsig_notification_worker(FAR void *arg) | |
|
|
||
| /* Perform the callback */ | ||
|
|
||
| #ifdef CONFIG_FDPIC | ||
| /* The worker does not carry the module's data base. Install the base | ||
| * captured at registration around the call. A zero base means the | ||
| * callback is not a module's. | ||
| */ | ||
|
|
||
| if (work->desc.got != 0) | ||
| { | ||
| fdpic_invoke((uintptr_t)work->value.sival_ptr, &work->desc); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get it. |
||
| } | ||
| else | ||
| { | ||
| ((sigev_notify_function_t)work->desc.entry)(work->value); | ||
| } | ||
| #else | ||
| work->func(work->value); | ||
| #endif | ||
| } | ||
|
|
||
| #endif /* CONFIG_SIG_EVTHREAD */ | ||
|
|
@@ -155,7 +175,11 @@ int nxsig_notification(pid_t pid, FAR struct sigevent *event, | |
| /* Initialize the work information */ | ||
|
|
||
| work->value = event->sigev_value; | ||
| #ifdef CONFIG_FDPIC | ||
| work->desc.entry = (uintptr_t)event->sigev_notify_function; | ||
| #else | ||
| work->func = event->sigev_notify_function; | ||
| #endif | ||
|
|
||
| /* Then queue the work */ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,10 @@ | |
| #include <nuttx/kthread.h> | ||
| #include <nuttx/fs/fs.h> | ||
|
|
||
| #ifdef CONFIG_FDPIC | ||
| # include <nuttx/fdpic.h> | ||
| #endif | ||
|
|
||
| #include "sched/sched.h" | ||
| #include "group/group.h" | ||
| #include "task/task.h" | ||
|
|
@@ -202,8 +206,18 @@ int task_create_with_stack(FAR const char *name, int priority, | |
| FAR void *stack_addr, int stack_size, | ||
| main_t entry, FAR char * const argv[]) | ||
| { | ||
| int ret = nxtask_create(name, priority, stack_addr, | ||
| stack_size, entry, argv, NULL); | ||
| int ret; | ||
|
|
||
| #ifdef CONFIG_FDPIC | ||
| /* Resolve here, once: this covers task_create() too, which is a plain | ||
| * forwarder. The new task inherits the creator's D-Space. | ||
| */ | ||
|
|
||
| entry = (main_t)fdpic_callback((FAR void *)entry); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but why not change the invocation point by fdpic_invoke instead?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the new task already gets r9 from the inherited dspace ( |
||
| #endif | ||
|
|
||
| ret = nxtask_create(name, priority, stack_addr, | ||
| stack_size, entry, argv, NULL); | ||
| if (ret < 0) | ||
| { | ||
| set_errno(-ret); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we cast desc to function pointer directly for no fdpic case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can do it, for no benefit.