You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/03/08 23:21:49 UTC
[01/16] incubator-mynewt-larva git commit: MYNEWT-95: fix whitelist
enable/disable in the controller code.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master faa7814db -> 063324d36
MYNEWT-95: fix whitelist enable/disable in the controller code.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/8b94064d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/8b94064d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/8b94064d
Branch: refs/heads/master
Commit: 8b94064d7e45e7bc9336a8c25f3df6fdf96d553c
Parents: 8bc63a5
Author: wes3 <wi...@micosa.io>
Authored: Thu Mar 3 16:32:59 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Thu Mar 3 16:33:16 2016 -0800
----------------------------------------------------------------------
net/nimble/controller/src/ble_ll_adv.c | 18 +++++++-----------
net/nimble/controller/src/ble_ll_conn.c | 3 +++
net/nimble/controller/src/ble_ll_scan.c | 17 +++++++----------
project/bletest/src/main.c | 4 ++--
4 files changed, 19 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8b94064d/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c
index c8a3255..352cfb1 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -387,6 +387,13 @@ ble_ll_adv_tx_start_cb(struct ble_ll_sched_item *sch)
STATS_INC(ble_ll_stats, adv_late_starts);
}
+ /* Enable/disable whitelisting based on filter policy */
+ if (advsm->adv_filter_policy != BLE_HCI_ADV_FILT_NONE) {
+ ble_ll_whitelist_enable();
+ } else {
+ ble_ll_whitelist_disable();
+ }
+
/* Set link layer state to advertising */
ble_ll_state_set(BLE_LL_STATE_ADV);
@@ -587,9 +594,6 @@ ble_ll_adv_sm_stop(struct ble_ll_adv_sm *advsm)
os_sr_t sr;
if (advsm->enabled) {
- /* Disable whitelisting (just in case) */
- ble_ll_whitelist_disable();
-
/* Remove any scheduled advertising items */
ble_ll_sched_rmv_elem(&advsm->adv_sch);
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
@@ -660,13 +664,6 @@ ble_ll_adv_sm_start(struct ble_ll_adv_sm *advsm)
adv_chan = ble_ll_adv_first_chan(advsm);
advsm->adv_chan = adv_chan;
- /* Enable/disable whitelisting based on filter policy */
- if (advsm->adv_filter_policy != BLE_HCI_ADV_FILT_NONE) {
- ble_ll_whitelist_enable();
- } else {
- ble_ll_whitelist_disable();
- }
-
/*
* Schedule advertising. We set the initial schedule start and end
* times to the earliest possible start/end.
@@ -1197,7 +1194,6 @@ ble_ll_adv_event_done(void *arg)
if (advsm->adv_pdu_start_time >= advsm->adv_dir_hd_end_time) {
/* Disable advertising */
advsm->enabled = 0;
- ble_ll_whitelist_disable();
ble_ll_conn_comp_event_send(NULL, BLE_ERR_DIR_ADV_TMO);
ble_ll_scan_chk_resume();
return;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8b94064d/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index 1d61c3d..36c63e3 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -789,6 +789,9 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
g_ble_ll_conn_cur_sm = connsm;
assert(connsm);
+ /* Disable whitelisting as connections do not use it */
+ ble_ll_whitelist_disable();
+
/* Set LL state */
ble_ll_state_set(BLE_LL_STATE_CONNECTION);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8b94064d/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index 32aee48..1f6704f 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -502,6 +502,13 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm, uint8_t chan)
/* Start receiving */
rc = ble_phy_rx();
if (!rc) {
+ /* Enable/disable whitelisting */
+ if (scansm->scan_filt_policy & 1) {
+ ble_ll_whitelist_enable();
+ } else {
+ ble_ll_whitelist_disable();
+ }
+
/* Set link layer state to scanning */
if (scansm->scan_type == BLE_SCAN_TYPE_INITIATE) {
ble_ll_state_set(BLE_LL_STATE_INITIATING);
@@ -590,9 +597,6 @@ ble_ll_scan_sm_stop(int chk_disable)
/* Disable phy */
ble_phy_disable();
- /* Disable whitelisting */
- ble_ll_whitelist_disable();
-
/* Set LL state to standby */
ble_ll_state_set(BLE_LL_STATE_STANDBY);
}
@@ -616,13 +620,6 @@ ble_ll_scan_sm_start(struct ble_ll_scan_sm *scansm)
}
}
- /* Enable/disable whitelisting */
- if (scansm->scan_filt_policy & 1) {
- ble_ll_whitelist_enable();
- } else {
- ble_ll_whitelist_disable();
- }
-
/* Count # of times started */
STATS_INC(ble_ll_stats, scan_starts);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8b94064d/project/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c
index a69e966..d004aa9 100755
--- a/project/bletest/src/main.c
+++ b/project/bletest/src/main.c
@@ -93,11 +93,11 @@ os_membuf_t g_mbuf_buffer[MBUF_MEMPOOL_SIZE];
#define BLETEST_CFG_ROLE (BLETEST_ROLE_INITIATOR)
//#define BLETEST_CFG_ROLE (BLETEST_ROLE_ADVERTISER)
//#define BLETEST_CFG_ROLE (BLETEST_ROLE_SCANNER)
-#define BLETEST_CFG_ADV_OWN_ADDR_TYPE (BLE_HCI_ADV_OWN_ADDR_RANDOM)
+#define BLETEST_CFG_ADV_OWN_ADDR_TYPE (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
#define BLETEST_CFG_ADV_PEER_ADDR_TYPE (BLE_HCI_ADV_PEER_ADDR_PUBLIC)
#define BLETEST_CFG_FILT_DUP_ADV (0)
#define BLETEST_CFG_ADV_ITVL (600000 / BLE_HCI_ADV_ITVL)
-#define BLETEST_CFG_ADV_TYPE BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD
+#define BLETEST_CFG_ADV_TYPE BLE_HCI_ADV_TYPE_ADV_IND
#define BLETEST_CFG_ADV_FILT_POLICY (BLE_HCI_ADV_FILT_NONE)
#define BLETEST_CFG_SCAN_ITVL (700000 / BLE_HCI_SCAN_ITVL)
#define BLETEST_CFG_SCAN_WINDOW (700000 / BLE_HCI_SCAN_ITVL)
[12/16] incubator-mynewt-larva git commit: The behavior of 'setjmp()'
is not portable across different UNIX systems. BSD derived systems including
OS X will the signal mask whereas Linux and Solaris do not (POSIX doesn't
specify behavior of setjmp/longjm
Posted by we...@apache.org.
The behavior of 'setjmp()' is not portable across different UNIX systems.
BSD derived systems including OS X will the signal mask whereas Linux and
Solaris do not (POSIX doesn't specify behavior of setjmp/longjmp with
respect to signal masks).
'sigsetjmp()' on the other hand takes an additional argument 'savemask'
that indicates whether the caller wants to save the signal mask or not.
In addition this function has the same behavior across all UNIX systems
so use this instead of '_setjmp()'.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/948d9055
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/948d9055
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/948d9055
Branch: refs/heads/master
Commit: 948d9055a03216c57bae2b521e38ab16db802faa
Parents: 701930d
Author: Neel Natu <ne...@nahannisys.com>
Authored: Sun Mar 6 22:56:49 2016 -0800
Committer: Neel Natu <ne...@nahannisys.com>
Committed: Sun Mar 6 22:56:49 2016 -0800
----------------------------------------------------------------------
libs/os/src/arch/sim/os_arch_sim.c | 6 +++---
libs/os/src/arch/sim/os_arch_stack_frame.s | 9 ++++++---
2 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/948d9055/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index 03975ce..18e40a1 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -35,7 +35,7 @@
struct stack_frame {
int sf_mainsp; /* stack on which main() is executing */
- jmp_buf sf_jb;
+ sigjmp_buf sf_jb;
int sf_sigsblocked;
struct os_task *sf_task;
};
@@ -55,8 +55,8 @@ extern void os_arch_frame_init(struct stack_frame *sf);
#define ISR_BLOCK_OFF (0)
#define ISR_BLOCK_ON (1)
-#define sim_setjmp(__jb) _setjmp(__jb)
-#define sim_longjmp(__jb, __ret) _longjmp(__jb, __ret)
+#define sim_setjmp(__jb) sigsetjmp(__jb, 0)
+#define sim_longjmp(__jb, __ret) siglongjmp(__jb, __ret)
sigset_t g_sigset;
volatile int g_block_isr = ISR_BLOCK_OFF;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/948d9055/libs/os/src/arch/sim/os_arch_stack_frame.s
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_stack_frame.s b/libs/os/src/arch/sim/os_arch_stack_frame.s
index 91c9338..81ce68b 100644
--- a/libs/os/src/arch/sim/os_arch_stack_frame.s
+++ b/libs/os/src/arch/sim/os_arch_stack_frame.s
@@ -40,15 +40,18 @@ _os_arch_frame_init:
* ----------------
* alignment padding variable (0 to 12 bytes)
* ----------------
- * pointer to sf_jb %esp
+ * savemask (0) 0x4(%esp)
+ * ----------------
+ * pointer to sf_jb 0x0(%esp)
* ----------------
*/
movl %esi,%esp
- subl $0x4,%esp /* make room for setjmp() argument */
+ subl $0x8,%esp /* make room for sigsetjmp() arguments */
andl $0xfffffff0,%esp /* align %esp on 16-byte boundary */
leal 0x4(%esi),%eax /* %eax = &sf->sf_jb */
movl %eax,0x0(%esp)
- call __setjmp /* _setjmp(sf->sf_jb) */
+ movl $0, 0x4(%esp)
+ call _sigsetjmp /* _setjmp(sf->sf_jb, 0) */
test %eax,%eax
jne 1f
movl 0x0(%esi),%esp /* switch back to the main() stack */
[04/16] incubator-mynewt-larva git commit: MYNEWT-4: Need the concept
of wallclock time
Posted by we...@apache.org.
MYNEWT-4: Need the concept of wallclock time
Add shell command "date" to set and get wallclock time.
The wallclock time is specified as per RFC 3339. For example:
date 2016-03-02T22:44:00 # set time to Mar 2 2016 10:44 PM UTC
date 2016-03-02T22:44:00Z # with explicit Zulu time zone (UTC + 0)
date 2016-03-02T22:44:00z # with explicit Zulu time zone (UTC + 0)
date 2016-03-02T22:44:00-08:00 # pacific standard time (UTC - 0800)
date 2016-03-02T22:44:00+05:30 # indian standard time (UTC + 0530)
date 2016-03-02T22:44:00.000031 # time is 22:44:00 + 31 usec
date 2016-03-02T22:44:00.1 # time is 22:44:00 + 100 msec
date 2016-03-02T22:44:00.013 # time is 22:44:00 + 13 msec
'os_settimeofday()' and 'os_gettimeofday()' can be used to set and get
the time of day.
'parse_datetime()' and 'format_datetime()' are available to parse and
format the RFC 3339 compliant datetime strings.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/bae36a76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/bae36a76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/bae36a76
Branch: refs/heads/master
Commit: bae36a7605dd3d97754df8188210e5dc304e1a6b
Parents: 22c393a
Author: neel <ne...@neels-Air.attlocal.net>
Authored: Wed Mar 2 23:01:16 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 10:53:53 2016 -0800
----------------------------------------------------------------------
LICENSE | 1 +
libs/os/src/os_time.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bae36a76/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 4948bfb..1ec8ffb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -305,3 +305,4 @@ This product bundles parts of mbed, which is available under the
* hw/mcu/nordic/nrf51xxx/include/mcu/nrf51_bitfields.h
* hw/mcu/nordic/nrf51xxx/include/mcu/nrf51_deprecated.h
* hw/mcu/nordic/nrf51xxx/include/mcu/system_nrf51.h
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bae36a76/libs/os/src/os_time.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_time.c b/libs/os/src/os_time.c
index 1b703e0..520747c 100644
--- a/libs/os/src/os_time.c
+++ b/libs/os/src/os_time.c
@@ -45,6 +45,27 @@ os_deltatime(os_time_t delta, const struct os_timeval *base,
os_timeradd(base, &tvdelta, result);
}
+/*
+ * Time-of-day collateral.
+ */
+static struct {
+ os_time_t ostime;
+ struct os_timeval uptime;
+ struct os_timeval utctime;
+ struct os_timezone timezone;
+} basetod;
+
+static void
+os_deltatime(os_time_t delta, const struct os_timeval *base,
+ struct os_timeval *result)
+{
+ struct os_timeval tvdelta;
+
+ tvdelta.tv_sec = delta / OS_TICKS_PER_SEC;
+ tvdelta.tv_usec = (delta % OS_TICKS_PER_SEC) * OS_USEC_PER_TICK;
+ os_timeradd(base, &tvdelta, result);
+}
+
os_time_t
os_time_get(void)
{
[11/16] incubator-mynewt-larva git commit: Add -fomit-frame-pointer
to default compiler flags for m4 as some assembly code wants to use r7 but
that register was being used for a frame pointer
Posted by we...@apache.org.
Add -fomit-frame-pointer to default compiler flags for m4 as some assembly code wants to use r7 but that register was being used for a frame pointer
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/701930d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/701930d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/701930d4
Branch: refs/heads/master
Commit: 701930d414f1c85ae1f72cc38df7bb43155b26d8
Parents: 3daf546
Author: wes3 <wi...@micosa.io>
Authored: Sun Mar 6 14:15:11 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 14:15:11 2016 -0800
----------------------------------------------------------------------
compiler/arm-none-eabi-m4/pkg.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/701930d4/compiler/arm-none-eabi-m4/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m4/pkg.yml b/compiler/arm-none-eabi-m4/pkg.yml
index 07dd418..5bb457c 100644
--- a/compiler/arm-none-eabi-m4/pkg.yml
+++ b/compiler/arm-none-eabi-m4/pkg.yml
@@ -37,7 +37,7 @@ compiler.path.objdump: arm-none-eabi-objdump
compiler.path.objsize: arm-none-eabi-size
compiler.path.objcopy: arm-none-eabi-objcopy
-compiler.flags.default: -mcpu=cortex-m4 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions
+compiler.flags.default: -mcpu=cortex-m4 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions -fomit-frame-pointer
compiler.flags.optimized: [compiler.flags.default, -Os -ggdb]
compiler.flags.debug: [compiler.flags.default, -O1 -ggdb]
[09/16] incubator-mynewt-larva git commit: Fix incorrect merge of
os_time.c
Posted by we...@apache.org.
Fix incorrect merge of os_time.c
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/f89e287b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f89e287b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f89e287b
Branch: refs/heads/master
Commit: f89e287b9dcafa9106e1304c1b9c69c851f17911
Parents: f208e19
Author: wes3 <wi...@micosa.io>
Authored: Sun Mar 6 11:18:36 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 11:18:36 2016 -0800
----------------------------------------------------------------------
libs/os/src/os_time.c | 21 ---------------------
1 file changed, 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f89e287b/libs/os/src/os_time.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_time.c b/libs/os/src/os_time.c
index 520747c..1b703e0 100644
--- a/libs/os/src/os_time.c
+++ b/libs/os/src/os_time.c
@@ -45,27 +45,6 @@ os_deltatime(os_time_t delta, const struct os_timeval *base,
os_timeradd(base, &tvdelta, result);
}
-/*
- * Time-of-day collateral.
- */
-static struct {
- os_time_t ostime;
- struct os_timeval uptime;
- struct os_timeval utctime;
- struct os_timezone timezone;
-} basetod;
-
-static void
-os_deltatime(os_time_t delta, const struct os_timeval *base,
- struct os_timeval *result)
-{
- struct os_timeval tvdelta;
-
- tvdelta.tv_sec = delta / OS_TICKS_PER_SEC;
- tvdelta.tv_usec = (delta % OS_TICKS_PER_SEC) * OS_USEC_PER_TICK;
- os_timeradd(base, &tvdelta, result);
-}
-
os_time_t
os_time_get(void)
{
[14/16] incubator-mynewt-larva git commit: This closes #13.
Restructure signal handling logic in 'sim' to make it similar to interrupts
on real hardware. This allows other interrupt sources beyond just timers in
sim (e.g. reads/write using aio).
Posted by we...@apache.org.
This closes #13.
Restructure signal handling logic in 'sim' to make it similar to interrupts on
real hardware. This allows other interrupt sources beyond just timers in sim
(e.g. reads/write using aio).
Switch the interval timer from ITIMER_VIRTUAL to ITIMER_REAL. This allows us
to yield when we are idle and still get track passage of time faithfully (to
do this with ITIMER_VIRTUAL requires busy waiting in the idle loop). This
change coupled with using 'sigsuspend()' in the idle loop gets the CPU
utilization from 100% to 4% at a timer frequency of 1000hz.
A detailed explanation of how context switching works with signals follows:
A voluntary context switch ends up with 'os_sched()' entering the critical
section and doing a 'longjmp()' to the task being scheduled. The new task
returns via 'os_sched()' and exits the critical section on its way out.
An involuntary context switch starts with a signal handler that enters a
critical section implicitly because all signals are masked when the handler
is executing. This in turn means that 'os_sched()' is running in a nested
critical section. The interrupted task remains on the run queue and resumes
execution in the signal handler when it runs again. The cpu executes with
signals/interrupts blocked until the handler returns at which time the
interrupted task gets control again.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/9a0f9aff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/9a0f9aff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/9a0f9aff
Branch: refs/heads/master
Commit: 9a0f9aff1c72feb4331b01035e1c7547b65380b2
Parents: f91d760
Author: Neel Natu <ne...@nahannisys.com>
Authored: Mon Mar 7 17:16:40 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Mon Mar 7 20:44:46 2016 -0800
----------------------------------------------------------------------
libs/os/include/os/arch/cortex_m0/os/os_arch.h | 1 +
libs/os/include/os/arch/cortex_m4/os/os_arch.h | 1 +
libs/os/include/os/arch/sim/os/os_arch.h | 3 +-
libs/os/src/arch/cortex_m0/os_arch_arm.c | 5 +
libs/os/src/arch/cortex_m4/os_arch_arm.c | 5 +
libs/os/src/arch/sim/os_arch_sim.c | 263 +++++++++-----------
libs/os/src/os.c | 1 +
7 files changed, 135 insertions(+), 144 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9a0f9aff/libs/os/include/os/arch/cortex_m0/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/cortex_m0/os/os_arch.h b/libs/os/include/os/arch/cortex_m0/os/os_arch.h
index b64534e..348a33a 100755
--- a/libs/os/include/os/arch/cortex_m0/os/os_arch.h
+++ b/libs/os/include/os/arch/cortex_m0/os/os_arch.h
@@ -68,6 +68,7 @@ os_error_t os_arch_os_start(void);
void os_set_env(void);
void os_arch_init_task_stack(os_stack_t *sf);
void os_default_irq_asm(void);
+void os_arch_idle(void);
/* External function prototypes supplied by BSP */
void os_bsp_systick_init(uint32_t os_ticks_per_sec);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9a0f9aff/libs/os/include/os/arch/cortex_m4/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/cortex_m4/os/os_arch.h b/libs/os/include/os/arch/cortex_m4/os/os_arch.h
index 0a3a507..299d95f 100755
--- a/libs/os/include/os/arch/cortex_m4/os/os_arch.h
+++ b/libs/os/include/os/arch/cortex_m4/os/os_arch.h
@@ -68,6 +68,7 @@ os_error_t os_arch_os_start(void);
void os_set_env(void);
void os_arch_init_task_stack(os_stack_t *sf);
void os_default_irq_asm(void);
+void os_arch_idle(void);
/* External function prototypes supplied by BSP */
void os_bsp_systick_init(uint32_t os_tick_per_sec);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9a0f9aff/libs/os/include/os/arch/sim/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/sim/os/os_arch.h b/libs/os/include/os/arch/sim/os/os_arch.h
index 68c835c..0934ab1 100644
--- a/libs/os/include/os/arch/sim/os/os_arch.h
+++ b/libs/os/include/os/arch/sim/os/os_arch.h
@@ -54,10 +54,11 @@ os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
void os_arch_ctx_sw(struct os_task *);
void os_arch_ctx_sw_isr(struct os_task *);
os_sr_t os_arch_save_sr(void);
-void os_arch_restore_sr(int);
+void os_arch_restore_sr(os_sr_t sr);
os_error_t os_arch_os_init(void);
void os_arch_os_stop(void);
os_error_t os_arch_os_start(void);
+void os_arch_idle(void);
void os_bsp_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9a0f9aff/libs/os/src/arch/cortex_m0/os_arch_arm.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/cortex_m0/os_arch_arm.c b/libs/os/src/arch/cortex_m0/os_arch_arm.c
index 1fd719b..ce5efd5 100755
--- a/libs/os/src/arch/cortex_m0/os_arch_arm.c
+++ b/libs/os/src/arch/cortex_m0/os_arch_arm.c
@@ -336,3 +336,8 @@ os_arch_os_start(void)
return err;
}
+void
+os_arch_idle(void)
+{
+ return;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9a0f9aff/libs/os/src/arch/cortex_m4/os_arch_arm.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/cortex_m4/os_arch_arm.c b/libs/os/src/arch/cortex_m4/os_arch_arm.c
index 64ba05e..439d7e7 100755
--- a/libs/os/src/arch/cortex_m4/os_arch_arm.c
+++ b/libs/os/src/arch/cortex_m4/os_arch_arm.c
@@ -349,3 +349,8 @@ os_arch_os_start(void)
return err;
}
+void
+os_arch_idle(void)
+{
+ return;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9a0f9aff/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index 18e40a1..9e08ea1 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -36,7 +36,6 @@
struct stack_frame {
int sf_mainsp; /* stack on which main() is executing */
sigjmp_buf sf_jb;
- int sf_sigsblocked;
struct os_task *sf_task;
};
@@ -49,47 +48,15 @@ CTASSERT(offsetof(struct stack_frame, sf_jb) == 4);
extern void os_arch_frame_init(struct stack_frame *sf);
-#define CTX_SWITCH_ISR (1)
-#define CTX_SWITCH_TASK (2)
-
-#define ISR_BLOCK_OFF (0)
-#define ISR_BLOCK_ON (1)
-
#define sim_setjmp(__jb) sigsetjmp(__jb, 0)
#define sim_longjmp(__jb, __ret) siglongjmp(__jb, __ret)
-sigset_t g_sigset;
-volatile int g_block_isr = ISR_BLOCK_OFF;
-
-static volatile int g_block_isr_on = ISR_BLOCK_ON;
-static volatile int g_block_isr_off = ISR_BLOCK_OFF;
-
-static int g_pending_ticks = 0;
-
-static void
-isr_state(volatile int *state, volatile int *ostate)
-{
- if (ostate) {
- *ostate = g_block_isr;
- }
+#define OS_ASSERT_CRITICAL() (assert(os_arch_in_critical()))
- if (state) {
- g_block_isr = *state;
- }
-}
+#define OS_USEC_PER_TICK (1000000 / OS_TICKS_PER_SEC)
-
-static void
-sigs_unblock(void)
-{
- sigprocmask(SIG_UNBLOCK, &g_sigset, NULL);
-}
-
-static void
-sigs_block(void)
-{
- sigprocmask(SIG_BLOCK, &g_sigset, NULL);
-}
+static int os_arch_in_critical(void);
+static sigset_t allsigs, nosigs;
/*
* Called from 'os_arch_frame_init()' when setjmp returns indirectly via
@@ -100,14 +67,17 @@ os_arch_task_start(struct stack_frame *sf, int rc)
{
struct os_task *task;
- task = sf->sf_task;
-
- isr_state(&g_block_isr_off, NULL);
-
- if (rc == CTX_SWITCH_ISR) {
- sigs_unblock();
- }
+ /*
+ * Interrupts are disabled when a task starts executing. This happens in
+ * two different ways:
+ * - via os_arch_os_start() for the first task.
+ * - via os_sched() for all other tasks.
+ *
+ * Enable interrupts before starting the task.
+ */
+ OS_EXIT_CRITICAL(0);
+ task = sf->sf_task;
task->t_func(task->t_arg);
/* This should never return */
@@ -120,12 +90,9 @@ os_arch_task_stack_init(struct os_task *t, os_stack_t *stack_top, int size)
struct stack_frame *sf;
sf = (struct stack_frame *) ((uint8_t *) stack_top - sizeof(*sf));
- sf->sf_sigsblocked = 0;
sf->sf_task = t;
- isr_state(&g_block_isr_on, NULL);
os_arch_frame_init(sf);
- isr_state(&g_block_isr_off, NULL);
return ((os_stack_t *)sf);
}
@@ -137,15 +104,14 @@ os_arch_ctx_sw(struct os_task *next_t)
struct stack_frame *sf;
int rc;
+ OS_ASSERT_CRITICAL();
t = os_sched_get_current_task();
if (t) {
sf = (struct stack_frame *) t->t_stackptr;
rc = sim_setjmp(sf->sf_jb);
if (rc != 0) {
- if (rc == CTX_SWITCH_ISR) {
- sigs_unblock();
- }
+ OS_ASSERT_CRITICAL();
return;
}
}
@@ -155,136 +121,147 @@ os_arch_ctx_sw(struct os_task *next_t)
os_sched_set_current_task(next_t);
sf = (struct stack_frame *) next_t->t_stackptr;
- /* block signals if the task we switch to expects them blocked. */
- if (sf->sf_sigsblocked) {
- sigs_block();
- rc = CTX_SWITCH_ISR;
- } else {
- rc = CTX_SWITCH_TASK;
- }
-
- sim_longjmp(sf->sf_jb, rc);
+ sim_longjmp(sf->sf_jb, 1);
}
void
os_arch_ctx_sw_isr(struct os_task *next_t)
{
- struct os_task *t;
- struct stack_frame *sf;
- int isr_ctx;
- volatile int block_isr_off;
- int rc;
+ os_arch_ctx_sw(next_t);
+}
- block_isr_off = g_block_isr_off;
+/*
+ * Disable signals and enter a critical section.
+ *
+ * Returns 1 if signals were already blocked and 0 otherwise.
+ */
+os_sr_t
+os_arch_save_sr(void)
+{
+ int error;
+ sigset_t omask;
- t = os_sched_get_current_task();
- if (t) {
- sf = (struct stack_frame *) t->t_stackptr;
-
- /* block signals coming from an interrupt context */
- sf->sf_sigsblocked = 1;
+ error = sigprocmask(SIG_BLOCK, &allsigs, &omask);
+ assert(error == 0);
- isr_state(&g_block_isr_on, &isr_ctx);
+ return (omask == allsigs);
+}
- rc = sim_setjmp(sf->sf_jb);
- if (rc != 0) {
- sf->sf_sigsblocked = 0;
- isr_state(&block_isr_off, NULL);
- return;
- }
- }
+void
+os_arch_restore_sr(os_sr_t osr)
+{
+ int error;
- isr_state(&block_isr_off, NULL);
+ OS_ASSERT_CRITICAL();
+ assert(osr == 0 || osr == 1);
- os_sched_ctx_sw_hook(next_t);
+ if (osr == 1) {
+ /* Exiting a nested critical section */
+ return;
+ }
- os_sched_set_current_task(next_t);
-
- sf = (struct stack_frame *) next_t->t_stackptr;
- sim_longjmp(sf->sf_jb, CTX_SWITCH_ISR);
+ error = sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
+ assert(error == 0);
}
-os_sr_t
-os_arch_save_sr(void)
+static int
+os_arch_in_critical(void)
{
- int isr_ctx;
+ int error;
+ sigset_t omask;
- isr_state(&g_block_isr_on, &isr_ctx);
+ error = sigprocmask(SIG_SETMASK, NULL, &omask);
+ assert(error == 0);
- return (isr_ctx);
+ return (omask == allsigs);
}
void
-os_arch_restore_sr(int isr_ctx)
+os_arch_idle(void)
{
- if (isr_ctx == ISR_BLOCK_ON) {
- return;
- } else {
- isr_state(&g_block_isr_off, NULL);
- }
+ assert(!os_arch_in_critical());
+
+ sigsuspend(&nosigs); /* Wait for a signal to wake us up */
}
static void timer_handler(int sig);
+static struct {
+ int num;
+ void (*handler)(int sig);
+} signals[] = {
+ { SIGALRM, timer_handler },
+};
+
+#define NUMSIGS (sizeof(signals)/sizeof(signals[0]))
+
static void
-initialize_signals(void)
+signals_init(void)
{
+ int i, error;
struct sigaction sa;
- sigemptyset(&g_sigset);
- sigaddset(&g_sigset, SIGALRM);
- sigaddset(&g_sigset, SIGVTALRM);
-
- memset(&sa, 0, sizeof sa);
- sa.sa_handler = timer_handler;
+ sigemptyset(&nosigs);
+ sigemptyset(&allsigs);
+ for (i = 0; i < NUMSIGS; i++) {
+ sigaddset(&allsigs, signals[i].num);
+ }
- sigaction(SIGALRM, &sa, NULL);
- sigaction(SIGVTALRM, &sa, NULL);
+ for (i = 0; i < NUMSIGS; i++) {
+ memset(&sa, 0, sizeof sa);
+ sa.sa_handler = signals[i].handler;
+ sa.sa_mask = allsigs;
+ error = sigaction(signals[i].num, &sa, NULL);
+ assert(error == 0);
+ }
}
static void
-cancel_signals(void)
+signals_cleanup(void)
{
+ int i, error;
struct sigaction sa;
- memset(&sa, 0, sizeof sa);
- sa.sa_handler = SIG_DFL;
-
- sigaction(SIGALRM, &sa, NULL);
- sigaction(SIGVTALRM, &sa, NULL);
+ for (i = 0; i < NUMSIGS; i++) {
+ memset(&sa, 0, sizeof sa);
+ sa.sa_handler = SIG_DFL;
+ error = sigaction(signals[i].num, &sa, NULL);
+ assert(error == 0);
+ }
}
static void
timer_handler(int sig)
{
+ struct timeval time_now, time_diff;
+ int ticks;
+
static struct timeval time_last;
static int time_inited;
- struct timeval time_now, time_diff;
- int isr_ctx;
if (!time_inited) {
gettimeofday(&time_last, NULL);
time_inited = 1;
}
- isr_state(NULL, &isr_ctx);
- if (isr_ctx == ISR_BLOCK_ON) {
- ++g_pending_ticks;
- return;
- }
-
gettimeofday(&time_now, NULL);
timersub(&time_now, &time_last, &time_diff);
- g_pending_ticks = time_diff.tv_usec / 1000;
+ ticks = time_diff.tv_sec * OS_TICKS_PER_SEC;
+ ticks += time_diff.tv_usec / OS_USEC_PER_TICK;
- while (--g_pending_ticks >= 0) {
+ while (--ticks >= 0) {
os_time_tick();
os_callout_tick();
}
- time_last = time_now;
- g_pending_ticks = 0;
+ /*
+ * Update 'time_last' but account for the remainder usecs that did not
+ * contribute towards whole 'ticks'.
+ */
+ time_diff.tv_sec = 0;
+ time_diff.tv_usec %= OS_USEC_PER_TICK;
+ timersub(&time_now, &time_diff, &time_last);
os_sched_os_timer_exp();
os_sched(NULL, 1);
@@ -296,21 +273,14 @@ start_timer(void)
struct itimerval it;
int rc;
- initialize_signals();
-
- /* 1 msec OS tick */
memset(&it, 0, sizeof(it));
it.it_value.tv_sec = 0;
- it.it_value.tv_usec = 1000;
+ it.it_value.tv_usec = OS_USEC_PER_TICK;
it.it_interval.tv_sec = 0;
- it.it_interval.tv_usec = 1000;
+ it.it_interval.tv_usec = OS_USEC_PER_TICK;
- rc = setitimer(ITIMER_VIRTUAL, &it, NULL);
- if (rc != 0) {
- const char msg[] = "Cannot set itimer";
- write(2, msg, sizeof(msg));
- _exit(1);
- }
+ rc = setitimer(ITIMER_REAL, &it, NULL);
+ assert(rc == 0);
}
static void
@@ -321,14 +291,8 @@ stop_timer(void)
memset(&it, 0, sizeof(it));
- rc = setitimer(ITIMER_VIRTUAL, &it, NULL);
- if (rc != 0) {
- const char msg[] = "Cannot stop itimer";
- write(2, msg, sizeof(msg));
- _exit(1);
- }
-
- cancel_signals();
+ rc = setitimer(ITIMER_REAL, &it, NULL);
+ assert(rc == 0);
}
os_error_t
@@ -352,7 +316,19 @@ os_arch_os_start(void)
{
struct stack_frame *sf;
struct os_task *t;
+ os_sr_t sr;
+
+ /* Setup all interrupt handlers */
+ signals_init();
+
+ /*
+ * Disable interrupts before enabling any interrupt sources. Pending
+ * interrupts will be recognized when the first task starts executing.
+ */
+ OS_ENTER_CRITICAL(sr);
+ assert(sr == 0);
+ /* Enable the interrupt sources */
start_timer();
t = os_sched_next_task();
@@ -361,7 +337,7 @@ os_arch_os_start(void)
g_os_started = 1;
sf = (struct stack_frame *) t->t_stackptr;
- sim_longjmp(sf->sf_jb, CTX_SWITCH_TASK);
+ sim_longjmp(sf->sf_jb, 1);
return 0;
}
@@ -374,5 +350,6 @@ void
os_arch_os_stop(void)
{
stop_timer();
+ signals_cleanup();
g_os_started = 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9a0f9aff/libs/os/src/os.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os.c b/libs/os/src/os.c
index dd43cf0..078800a 100644
--- a/libs/os/src/os.c
+++ b/libs/os/src/os.c
@@ -37,6 +37,7 @@ os_idle_task(void *arg)
/* For now, idle task simply increments a counter to show it is running. */
while (1) {
++g_os_idle_ctr;
+ os_arch_idle();
}
}
[05/16] incubator-mynewt-larva git commit: Support building the 'sim'
with optimization levels higher than -O0. The higher optimization levels emit
useful warnings that are masked at -O0.
Posted by we...@apache.org.
Support building the 'sim' with optimization levels higher than -O0. The
higher optimization levels emit useful warnings that are masked at -O0.
The basic problem with the implementation of 'os_arch_task_stack_init()'
is that we are switching stacks from underneath the compiler without any
ability to influence how the compiler uses the stack. Thus when setjmp()
returns the compiler doesn't know that the stack frame it allocated for
local variables doesn't exist anymore on the new stack.
This happens to work with the -O0 optimization level because the compiler
addresses local variables using the frame pointer (%ebp). Higher optimization
levels use offsets from the stack pointer and immediately expose the issue
mentioned above.
Fix this by switching stacks in 'os_arch_frame_init()' which is implemented
in assembly so we can control the use of stack after setjmp() returns.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/55afa1c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/55afa1c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/55afa1c6
Branch: refs/heads/master
Commit: 55afa1c6035d9841413924b44bb6225333102083
Parents: 9717c79
Author: Neel Natu <ne...@nahannisys.com>
Authored: Fri Mar 4 18:13:55 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 10:53:54 2016 -0800
----------------------------------------------------------------------
compiler/sim/pkg.yml | 7 ++-
libs/os/src/arch/sim/os_arch_sim.c | 84 ++++++++++++-------------
libs/os/src/arch/sim/os_arch_stack_frame.s | 68 ++++++++++++++++++++
libs/util/include/util/util.h | 2 +
4 files changed, 113 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/55afa1c6/compiler/sim/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/pkg.yml b/compiler/sim/pkg.yml
index de62ed9..c9ace8f 100644
--- a/compiler/sim/pkg.yml
+++ b/compiler/sim/pkg.yml
@@ -29,15 +29,16 @@ pkg.keywords:
- gcc
compiler.path.cc: "/usr/local/bin/gcc-5"
+compiler.path.as: "/usr/local/bin/gcc-5 -x assembler-with-cpp"
compiler.path.archive: "ar"
compiler.path.objdump: "gobjdump"
compiler.path.objsize: "objsize"
compiler.path.objcopy: "gobjcopy"
compiler.flags.base: >
- -m32 -Wall -Werror -ggdb -O0 -DMN_OSX
+ -m32 -Wall -Werror -ggdb -DMN_OSX
-compiler.flags.default: [compiler.flags.base]
-compiler.flags.debug: [compiler.flags.base, -ggdb -O0]
+compiler.flags.default: [compiler.flags.base, -O1]
+compiler.flags.debug: [compiler.flags.base, -O0]
compiler.ld.mapfile: false
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/55afa1c6/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index d22f8a2..03975ce 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -31,19 +31,24 @@
#include <signal.h>
#include <sys/time.h>
#include <assert.h>
+#include <util/util.h>
-/* XXX:
- * Stack must be 16-byte aligned, any changes to this structure
- * must keep that alignment.
- */
struct stack_frame {
+ int sf_mainsp; /* stack on which main() is executing */
jmp_buf sf_jb;
int sf_sigsblocked;
- os_task_func_t sf_func;
- void *sf_arg;
- int _pad[3];
+ struct os_task *sf_task;
};
+/*
+ * Assert that 'sf_mainsp' and 'sf_jb' are at the specific offsets where
+ * os_arch_frame_init() expects them to be.
+ */
+CTASSERT(offsetof(struct stack_frame, sf_mainsp) == 0);
+CTASSERT(offsetof(struct stack_frame, sf_jb) == 4);
+
+extern void os_arch_frame_init(struct stack_frame *sf);
+
#define CTX_SWITCH_ISR (1)
#define CTX_SWITCH_TASK (2)
@@ -86,54 +91,43 @@ sigs_block(void)
sigprocmask(SIG_BLOCK, &g_sigset, NULL);
}
-os_stack_t *
-os_arch_task_stack_init(struct os_task *t, os_stack_t *stack_top, int size)
+/*
+ * Called from 'os_arch_frame_init()' when setjmp returns indirectly via
+ * longjmp. The return value of setjmp is passed to this function as 'rc'.
+ */
+void
+os_arch_task_start(struct stack_frame *sf, int rc)
{
- struct os_task *cur_t;
- struct stack_frame *sf;
- os_stack_t *s;
- void *s_cur;
- volatile int block_isr_off;
- int rc;
+ struct os_task *task;
- s = (os_stack_t *) ((uint8_t *) stack_top - sizeof(*sf));
- sf = (struct stack_frame *) s;
- sf->sf_sigsblocked = 0;
- sf->sf_func = t->t_func;
- sf->sf_arg = t->t_arg;
+ task = sf->sf_task;
- block_isr_off = g_block_isr_off;
+ isr_state(&g_block_isr_off, NULL);
- /* Save the current stack pointer, and then trick setjmp()
- * to store the stackos stack pointer.
- */
- asm("movl %%esp, %0" : "=r" (s_cur));
- asm("movl %0,%%esp" : /* no output */ : "r" (s));
+ if (rc == CTX_SWITCH_ISR) {
+ sigs_unblock();
+ }
- isr_state(&g_block_isr_on, NULL);
+ task->t_func(task->t_arg);
- rc = sim_setjmp(sf->sf_jb);
- if (rc != 0) {
- cur_t = os_sched_get_current_task();
-
- isr_state(&block_isr_off, NULL);
+ /* This should never return */
+ assert(0);
+}
- if (rc == CTX_SWITCH_ISR) {
- sigs_unblock();
- }
+os_stack_t *
+os_arch_task_stack_init(struct os_task *t, os_stack_t *stack_top, int size)
+{
+ struct stack_frame *sf;
- sf = (struct stack_frame *) cur_t->t_stackptr;
- sf->sf_func(sf->sf_arg);
+ sf = (struct stack_frame *) ((uint8_t *) stack_top - sizeof(*sf));
+ sf->sf_sigsblocked = 0;
+ sf->sf_task = t;
- /* This should never return */
- assert(0);
- } else {
- /* restore current stack pointer */
- isr_state(&g_block_isr_off, NULL);
- asm("movl %0, %%esp" : /* no output */ : "r" (s_cur));
- }
+ isr_state(&g_block_isr_on, NULL);
+ os_arch_frame_init(sf);
+ isr_state(&g_block_isr_off, NULL);
- return (s);
+ return ((os_stack_t *)sf);
}
void
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/55afa1c6/libs/os/src/arch/sim/os_arch_stack_frame.s
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_stack_frame.s b/libs/os/src/arch/sim/os_arch_stack_frame.s
new file mode 100644
index 0000000..91c9338
--- /dev/null
+++ b/libs/os/src/arch/sim/os_arch_stack_frame.s
@@ -0,0 +1,68 @@
+ .text
+ .code32
+ .p2align 4, 0x90 /* align on 16-byte boundary and fill with NOPs */
+
+ .globl _os_arch_frame_init
+ /*
+ * void os_arch_frame_init(struct stack_frame *sf)
+ */
+_os_arch_frame_init:
+ push %ebp /* function prologue for backtrace */
+ mov %esp,%ebp
+ push %esi /* save %esi before using it as a tmpreg */
+
+ /*
+ * At this point we are executing on the main() stack:
+ * ----------------
+ * stack_frame ptr 0xc(%esp)
+ * ----------------
+ * return address 0x8(%esp)
+ * ----------------
+ * saved ebp 0x4(%esp)
+ * ----------------
+ * saved esi 0x0(%esp)
+ * ----------------
+ */
+ movl 0xc(%esp),%esi /* %esi = 'sf' */
+ movl %esp,0x0(%esi) /* sf->mainsp = %esp */
+
+ /*
+ * Switch the stack so the stack pointer stored in 'sf->sf_jb' points
+ * to the task stack. This is slightly complicated because OS X wants
+ * the incoming stack pointer to be 16-byte aligned.
+ *
+ * ----------------
+ * sf (other fields)
+ * ----------------
+ * sf (sf_jb) 0x4(%esi)
+ * ----------------
+ * sf (sf_mainsp) 0x0(%esi)
+ * ----------------
+ * alignment padding variable (0 to 12 bytes)
+ * ----------------
+ * pointer to sf_jb %esp
+ * ----------------
+ */
+ movl %esi,%esp
+ subl $0x4,%esp /* make room for setjmp() argument */
+ andl $0xfffffff0,%esp /* align %esp on 16-byte boundary */
+ leal 0x4(%esi),%eax /* %eax = &sf->sf_jb */
+ movl %eax,0x0(%esp)
+ call __setjmp /* _setjmp(sf->sf_jb) */
+ test %eax,%eax
+ jne 1f
+ movl 0x0(%esi),%esp /* switch back to the main() stack */
+ pop %esi
+ pop %ebp
+ ret /* return to os_arch_task_stack_init() */
+1:
+ lea 2f,%ecx
+ push %ecx /* retaddr */
+ push $0 /* frame pointer */
+ movl %esp,%ebp /* handcrafted prologue for backtrace */
+ push %eax /* rc */
+ push %esi /* sf */
+ call _os_arch_task_start /* os_arch_task_start(sf, rc) */
+ /* never returns */
+2:
+ nop
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/55afa1c6/libs/util/include/util/util.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/util.h b/libs/util/include/util/util.h
index 6b3dd8b..1dcdab4 100644
--- a/libs/util/include/util/util.h
+++ b/libs/util/include/util/util.h
@@ -19,4 +19,6 @@
#ifndef __UTIL_H__
#define __UTIL_H__
+#define CTASSERT(x) typedef int __ctasssert ## __LINE__[(x) ? 1 : -1]
+
#endif /* __UTIL_H__ */
[02/16] incubator-mynewt-larva git commit: MYNEWT-230
Posted by we...@apache.org.
MYNEWT-230
explictely cast to an integer since some compilers don't like to implicitelty
cast a char to an int
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/ee324af2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/ee324af2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/ee324af2
Branch: refs/heads/master
Commit: ee324af2dcc761a6c4125b3d374894f2811a5459
Parents: 8b94064
Author: Paul Dietrich <pa...@yahoo.com>
Authored: Thu Mar 3 17:11:13 2016 -0800
Committer: Paul Dietrich <pa...@yahoo.com>
Committed: Thu Mar 3 17:12:23 2016 -0800
----------------------------------------------------------------------
libs/util/src/datetime.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/ee324af2/libs/util/src/datetime.c
----------------------------------------------------------------------
diff --git a/libs/util/src/datetime.c b/libs/util/src/datetime.c
index 902eb55..fe4fb38 100644
--- a/libs/util/src/datetime.c
+++ b/libs/util/src/datetime.c
@@ -211,7 +211,7 @@ parse_number(const char *str, int digits, int *val)
cp = str;
end = str + digits;
while (cp < end) {
- if (!isdigit(*cp)) {
+ if (!isdigit((int) *cp)) {
return (NULL);
}
*val *= 10;
@@ -277,7 +277,7 @@ parse_datetime(const char *input, struct os_timeval *tv, struct os_timezone *tz)
/* parse fractional seconds if specified */
if (*cp == '.') {
ep = ++cp;
- while (isdigit(*ep)) {
+ while (isdigit((int) *ep)) {
ep++;
}
digits = ep - cp;
[03/16] incubator-mynewt-larva git commit: Merge branch 'MYNEWT-230'
of https://github.com/paulfdietrich/incubator-mynewt-larva into develop
Posted by we...@apache.org.
Merge branch 'MYNEWT-230' of https://github.com/paulfdietrich/incubator-mynewt-larva into develop
This closes #10.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/22c393a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/22c393a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/22c393a4
Branch: refs/heads/master
Commit: 22c393a405e9d6f95bf2b1de359b0b70bf4c89c9
Parents: db0e97b ee324af
Author: aditihilbert <ad...@runtime.io>
Authored: Fri Mar 4 15:06:42 2016 -0800
Committer: aditihilbert <ad...@runtime.io>
Committed: Fri Mar 4 15:06:42 2016 -0800
----------------------------------------------------------------------
libs/util/src/datetime.c | 4 ++--
net/nimble/controller/src/ble_ll_adv.c | 18 +++++++-----------
net/nimble/controller/src/ble_ll_conn.c | 3 +++
net/nimble/controller/src/ble_ll_scan.c | 17 +++++++----------
project/bletest/src/main.c | 4 ++--
5 files changed, 21 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
[08/16] incubator-mynewt-larva git commit: Merge branch 'develop' of
https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva into develop
Posted by we...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva into develop
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/f208e198
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f208e198
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f208e198
Branch: refs/heads/master
Commit: f208e19876b7d4a239c4ff0ea22f2f81bb6b2884
Parents: 6440a4a 55afa1c
Author: wes3 <wi...@micosa.io>
Authored: Sun Mar 6 11:05:55 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 11:05:55 2016 -0800
----------------------------------------------------------------------
----------------------------------------------------------------------
[06/16] incubator-mynewt-larva git commit: Don't drop the critical
section between selecting the task to run and actually switching to it. This
creates a window where an interrupt might make a higher priority task
runnable but won't switch to it immediat
Posted by we...@apache.org.
Don't drop the critical section between selecting the task to run and
actually switching to it. This creates a window where an interrupt might
make a higher priority task runnable but won't switch to it immediately.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/9717c796
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/9717c796
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/9717c796
Branch: refs/heads/master
Commit: 9717c7964bf8047a975eb5977b064fba4c10a88a
Parents: bae36a7
Author: Neel Natu <ne...@nahannisys.com>
Authored: Fri Mar 4 18:07:14 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 10:53:54 2016 -0800
----------------------------------------------------------------------
libs/os/src/os_sched.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9717c796/libs/os/src/os_sched.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_sched.c b/libs/os/src/os_sched.c
index d5ce25d..5ffd14c 100644
--- a/libs/os/src/os_sched.c
+++ b/libs/os/src/os_sched.c
@@ -138,16 +138,15 @@ os_sched(struct os_task *next_t, int isr)
}
if (next_t != g_current_task) {
- OS_EXIT_CRITICAL(sr);
if (isr) {
os_arch_ctx_sw_isr(next_t);
} else {
os_arch_ctx_sw(next_t);
}
- } else {
- OS_EXIT_CRITICAL(sr);
}
+
+ OS_EXIT_CRITICAL(sr);
}
/**
[07/16] incubator-mynewt-larva git commit: This closes #11. Support
building the 'sim' with optimization levels higher than -O0. The higher
optimization levels emit useful warnings that are masked at -O0.
Posted by we...@apache.org.
This closes #11.
Support building the 'sim' with optimization levels higher than -O0. The
higher optimization levels emit useful warnings that are masked at -O0.
The basic problem with the implementation of 'os_arch_task_stack_init()'
is that we are switching stacks from underneath the compiler without any
ability to influence how the compiler uses the stack. Thus when setjmp()
returns the compiler doesn't know that the stack frame it allocated for
local variables doesn't exist anymore on the new stack.
This happens to work with the -O0 optimization level because the compiler
addresses local variables using the frame pointer (%ebp). Higher optimization
levels use offsets from the stack pointer and immediately expose the issue
mentioned above.
Fix this by switching stacks in 'os_arch_frame_init()' which is implemented
in assembly so we can control the use of stack after setjmp() returns.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/6440a4aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/6440a4aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/6440a4aa
Branch: refs/heads/master
Commit: 6440a4aa3043a2c0985050dfb996d391f7beccc4
Parents: 9717c79
Author: Neel Natu <ne...@nahannisys.com>
Authored: Fri Mar 4 18:13:55 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 11:05:19 2016 -0800
----------------------------------------------------------------------
compiler/sim/pkg.yml | 7 ++-
libs/os/src/arch/sim/os_arch_sim.c | 84 ++++++++++++-------------
libs/os/src/arch/sim/os_arch_stack_frame.s | 68 ++++++++++++++++++++
libs/util/include/util/util.h | 2 +
4 files changed, 113 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/6440a4aa/compiler/sim/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/sim/pkg.yml b/compiler/sim/pkg.yml
index de62ed9..c9ace8f 100644
--- a/compiler/sim/pkg.yml
+++ b/compiler/sim/pkg.yml
@@ -29,15 +29,16 @@ pkg.keywords:
- gcc
compiler.path.cc: "/usr/local/bin/gcc-5"
+compiler.path.as: "/usr/local/bin/gcc-5 -x assembler-with-cpp"
compiler.path.archive: "ar"
compiler.path.objdump: "gobjdump"
compiler.path.objsize: "objsize"
compiler.path.objcopy: "gobjcopy"
compiler.flags.base: >
- -m32 -Wall -Werror -ggdb -O0 -DMN_OSX
+ -m32 -Wall -Werror -ggdb -DMN_OSX
-compiler.flags.default: [compiler.flags.base]
-compiler.flags.debug: [compiler.flags.base, -ggdb -O0]
+compiler.flags.default: [compiler.flags.base, -O1]
+compiler.flags.debug: [compiler.flags.base, -O0]
compiler.ld.mapfile: false
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/6440a4aa/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index d22f8a2..03975ce 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -31,19 +31,24 @@
#include <signal.h>
#include <sys/time.h>
#include <assert.h>
+#include <util/util.h>
-/* XXX:
- * Stack must be 16-byte aligned, any changes to this structure
- * must keep that alignment.
- */
struct stack_frame {
+ int sf_mainsp; /* stack on which main() is executing */
jmp_buf sf_jb;
int sf_sigsblocked;
- os_task_func_t sf_func;
- void *sf_arg;
- int _pad[3];
+ struct os_task *sf_task;
};
+/*
+ * Assert that 'sf_mainsp' and 'sf_jb' are at the specific offsets where
+ * os_arch_frame_init() expects them to be.
+ */
+CTASSERT(offsetof(struct stack_frame, sf_mainsp) == 0);
+CTASSERT(offsetof(struct stack_frame, sf_jb) == 4);
+
+extern void os_arch_frame_init(struct stack_frame *sf);
+
#define CTX_SWITCH_ISR (1)
#define CTX_SWITCH_TASK (2)
@@ -86,54 +91,43 @@ sigs_block(void)
sigprocmask(SIG_BLOCK, &g_sigset, NULL);
}
-os_stack_t *
-os_arch_task_stack_init(struct os_task *t, os_stack_t *stack_top, int size)
+/*
+ * Called from 'os_arch_frame_init()' when setjmp returns indirectly via
+ * longjmp. The return value of setjmp is passed to this function as 'rc'.
+ */
+void
+os_arch_task_start(struct stack_frame *sf, int rc)
{
- struct os_task *cur_t;
- struct stack_frame *sf;
- os_stack_t *s;
- void *s_cur;
- volatile int block_isr_off;
- int rc;
+ struct os_task *task;
- s = (os_stack_t *) ((uint8_t *) stack_top - sizeof(*sf));
- sf = (struct stack_frame *) s;
- sf->sf_sigsblocked = 0;
- sf->sf_func = t->t_func;
- sf->sf_arg = t->t_arg;
+ task = sf->sf_task;
- block_isr_off = g_block_isr_off;
+ isr_state(&g_block_isr_off, NULL);
- /* Save the current stack pointer, and then trick setjmp()
- * to store the stackos stack pointer.
- */
- asm("movl %%esp, %0" : "=r" (s_cur));
- asm("movl %0,%%esp" : /* no output */ : "r" (s));
+ if (rc == CTX_SWITCH_ISR) {
+ sigs_unblock();
+ }
- isr_state(&g_block_isr_on, NULL);
+ task->t_func(task->t_arg);
- rc = sim_setjmp(sf->sf_jb);
- if (rc != 0) {
- cur_t = os_sched_get_current_task();
-
- isr_state(&block_isr_off, NULL);
+ /* This should never return */
+ assert(0);
+}
- if (rc == CTX_SWITCH_ISR) {
- sigs_unblock();
- }
+os_stack_t *
+os_arch_task_stack_init(struct os_task *t, os_stack_t *stack_top, int size)
+{
+ struct stack_frame *sf;
- sf = (struct stack_frame *) cur_t->t_stackptr;
- sf->sf_func(sf->sf_arg);
+ sf = (struct stack_frame *) ((uint8_t *) stack_top - sizeof(*sf));
+ sf->sf_sigsblocked = 0;
+ sf->sf_task = t;
- /* This should never return */
- assert(0);
- } else {
- /* restore current stack pointer */
- isr_state(&g_block_isr_off, NULL);
- asm("movl %0, %%esp" : /* no output */ : "r" (s_cur));
- }
+ isr_state(&g_block_isr_on, NULL);
+ os_arch_frame_init(sf);
+ isr_state(&g_block_isr_off, NULL);
- return (s);
+ return ((os_stack_t *)sf);
}
void
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/6440a4aa/libs/os/src/arch/sim/os_arch_stack_frame.s
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_stack_frame.s b/libs/os/src/arch/sim/os_arch_stack_frame.s
new file mode 100644
index 0000000..91c9338
--- /dev/null
+++ b/libs/os/src/arch/sim/os_arch_stack_frame.s
@@ -0,0 +1,68 @@
+ .text
+ .code32
+ .p2align 4, 0x90 /* align on 16-byte boundary and fill with NOPs */
+
+ .globl _os_arch_frame_init
+ /*
+ * void os_arch_frame_init(struct stack_frame *sf)
+ */
+_os_arch_frame_init:
+ push %ebp /* function prologue for backtrace */
+ mov %esp,%ebp
+ push %esi /* save %esi before using it as a tmpreg */
+
+ /*
+ * At this point we are executing on the main() stack:
+ * ----------------
+ * stack_frame ptr 0xc(%esp)
+ * ----------------
+ * return address 0x8(%esp)
+ * ----------------
+ * saved ebp 0x4(%esp)
+ * ----------------
+ * saved esi 0x0(%esp)
+ * ----------------
+ */
+ movl 0xc(%esp),%esi /* %esi = 'sf' */
+ movl %esp,0x0(%esi) /* sf->mainsp = %esp */
+
+ /*
+ * Switch the stack so the stack pointer stored in 'sf->sf_jb' points
+ * to the task stack. This is slightly complicated because OS X wants
+ * the incoming stack pointer to be 16-byte aligned.
+ *
+ * ----------------
+ * sf (other fields)
+ * ----------------
+ * sf (sf_jb) 0x4(%esi)
+ * ----------------
+ * sf (sf_mainsp) 0x0(%esi)
+ * ----------------
+ * alignment padding variable (0 to 12 bytes)
+ * ----------------
+ * pointer to sf_jb %esp
+ * ----------------
+ */
+ movl %esi,%esp
+ subl $0x4,%esp /* make room for setjmp() argument */
+ andl $0xfffffff0,%esp /* align %esp on 16-byte boundary */
+ leal 0x4(%esi),%eax /* %eax = &sf->sf_jb */
+ movl %eax,0x0(%esp)
+ call __setjmp /* _setjmp(sf->sf_jb) */
+ test %eax,%eax
+ jne 1f
+ movl 0x0(%esi),%esp /* switch back to the main() stack */
+ pop %esi
+ pop %ebp
+ ret /* return to os_arch_task_stack_init() */
+1:
+ lea 2f,%ecx
+ push %ecx /* retaddr */
+ push $0 /* frame pointer */
+ movl %esp,%ebp /* handcrafted prologue for backtrace */
+ push %eax /* rc */
+ push %esi /* sf */
+ call _os_arch_task_start /* os_arch_task_start(sf, rc) */
+ /* never returns */
+2:
+ nop
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/6440a4aa/libs/util/include/util/util.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/util.h b/libs/util/include/util/util.h
index 6b3dd8b..1dcdab4 100644
--- a/libs/util/include/util/util.h
+++ b/libs/util/include/util/util.h
@@ -19,4 +19,6 @@
#ifndef __UTIL_H__
#define __UTIL_H__
+#define CTASSERT(x) typedef int __ctasssert ## __LINE__[(x) ? 1 : -1]
+
#endif /* __UTIL_H__ */
[10/16] incubator-mynewt-larva git commit: omit frame pointer in
default m0 builds as our assembly code uses r7 and gcc wanted to use it as a
frame pointer
Posted by we...@apache.org.
omit frame pointer in default m0 builds as our assembly code uses r7 and gcc wanted to use it as a frame pointer
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/3daf5463
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/3daf5463
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/3daf5463
Branch: refs/heads/master
Commit: 3daf5463d5bc3c53e9bef9e9b692938f1d15a393
Parents: f89e287
Author: wes3 <wi...@micosa.io>
Authored: Sun Mar 6 11:24:11 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Sun Mar 6 11:24:11 2016 -0800
----------------------------------------------------------------------
compiler/arm-none-eabi-m0/pkg.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/3daf5463/compiler/arm-none-eabi-m0/pkg.yml
----------------------------------------------------------------------
diff --git a/compiler/arm-none-eabi-m0/pkg.yml b/compiler/arm-none-eabi-m0/pkg.yml
index 0b215c9..c45947f 100644
--- a/compiler/arm-none-eabi-m0/pkg.yml
+++ b/compiler/arm-none-eabi-m0/pkg.yml
@@ -36,7 +36,7 @@ compiler.path.objdump: arm-none-eabi-objdump
compiler.path.objsize: arm-none-eabi-size
compiler.path.objcopy: arm-none-eabi-objcopy
-compiler.flags.default: -mcpu=cortex-m0 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions
+compiler.flags.default: -mcpu=cortex-m0 -mthumb-interwork -mthumb -Wall -Werror -fno-exceptions -fomit-frame-pointer
compiler.flags.optimized: [compiler.flags.default, -Os -ggdb]
compiler.flags.debug: [compiler.flags.default, -O1 -ggdb]
[13/16] incubator-mynewt-larva git commit: This closes #12. Fix
comment to reflect that we are calling 'sigsetjmp()'
Posted by we...@apache.org.
This closes #12.
Fix comment to reflect that we are calling 'sigsetjmp()'
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/f91d7603
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f91d7603
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f91d7603
Branch: refs/heads/master
Commit: f91d76037952d7f6723d85b4ec77235837d10763
Parents: 948d905
Author: Neel Natu <ne...@nahannisys.com>
Authored: Mon Mar 7 17:44:49 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Mon Mar 7 20:27:25 2016 -0800
----------------------------------------------------------------------
libs/os/src/arch/sim/os_arch_stack_frame.s | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f91d7603/libs/os/src/arch/sim/os_arch_stack_frame.s
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_stack_frame.s b/libs/os/src/arch/sim/os_arch_stack_frame.s
index 81ce68b..709ca29 100644
--- a/libs/os/src/arch/sim/os_arch_stack_frame.s
+++ b/libs/os/src/arch/sim/os_arch_stack_frame.s
@@ -51,7 +51,7 @@ _os_arch_frame_init:
leal 0x4(%esi),%eax /* %eax = &sf->sf_jb */
movl %eax,0x0(%esp)
movl $0, 0x4(%esp)
- call _sigsetjmp /* _setjmp(sf->sf_jb, 0) */
+ call _sigsetjmp /* sigsetjmp(sf->sf_jb, 0) */
test %eax,%eax
jne 1f
movl 0x0(%esi),%esp /* switch back to the main() stack */
[15/16] incubator-mynewt-larva git commit: This closes #14. The
implementation of 'os_arch_ctx_sw_isr()' is identical to 'os_arch_ctx_sw()'
for all architectures so get rid of it.
Posted by we...@apache.org.
This closes #14.
The implementation of 'os_arch_ctx_sw_isr()' is identical to 'os_arch_ctx_sw()'
for all architectures so get rid of it.
Also get rid of the 'isr' parameter to 'os_sched()' since it is not relevant
anymore.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/c6f7543a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/c6f7543a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/c6f7543a
Branch: refs/heads/master
Commit: c6f7543a7aac324ee29fcabed0eb6e7a76b46d66
Parents: 9a0f9af
Author: Neel Natu <ne...@nahannisys.com>
Authored: Mon Mar 7 17:41:38 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Mon Mar 7 21:08:19 2016 -0800
----------------------------------------------------------------------
libs/os/include/os/arch/cortex_m0/os/os_arch.h | 1 -
libs/os/include/os/arch/cortex_m4/os/os_arch.h | 1 -
libs/os/include/os/arch/sim/os/os_arch.h | 1 -
libs/os/include/os/os_eventq.h | 1 -
libs/os/include/os/os_sched.h | 2 +-
libs/os/src/arch/cortex_m0/os_arch_arm.c | 11 +----------
libs/os/src/arch/cortex_m4/os_arch_arm.c | 11 +----------
libs/os/src/arch/sim/os_arch_sim.c | 8 +-------
libs/os/src/os_callout.c | 2 +-
libs/os/src/os_eventq.c | 12 +++---------
libs/os/src/os_mutex.c | 4 ++--
libs/os/src/os_sched.c | 10 ++--------
libs/os/src/os_sem.c | 4 ++--
libs/os/src/os_time.c | 2 +-
14 files changed, 15 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/include/os/arch/cortex_m0/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/cortex_m0/os/os_arch.h b/libs/os/include/os/arch/cortex_m0/os/os_arch.h
index 348a33a..cd583d4 100755
--- a/libs/os/include/os/arch/cortex_m0/os/os_arch.h
+++ b/libs/os/include/os/arch/cortex_m0/os/os_arch.h
@@ -58,7 +58,6 @@ typedef uint32_t os_stack_t;
os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
void timer_handler(void);
void os_arch_ctx_sw(struct os_task *);
-void os_arch_ctx_sw_isr(struct os_task *);
os_sr_t os_arch_save_sr(void);
void os_arch_restore_sr(os_sr_t);
void os_arch_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/include/os/arch/cortex_m4/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/cortex_m4/os/os_arch.h b/libs/os/include/os/arch/cortex_m4/os/os_arch.h
index 299d95f..a88748c 100755
--- a/libs/os/include/os/arch/cortex_m4/os/os_arch.h
+++ b/libs/os/include/os/arch/cortex_m4/os/os_arch.h
@@ -58,7 +58,6 @@ typedef uint32_t os_stack_t;
os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
void timer_handler(void);
void os_arch_ctx_sw(struct os_task *);
-void os_arch_ctx_sw_isr(struct os_task *);
os_sr_t os_arch_save_sr(void);
void os_arch_restore_sr(os_sr_t);
void os_arch_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/include/os/arch/sim/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/sim/os/os_arch.h b/libs/os/include/os/arch/sim/os/os_arch.h
index 0934ab1..cfe737f 100644
--- a/libs/os/include/os/arch/sim/os/os_arch.h
+++ b/libs/os/include/os/arch/sim/os/os_arch.h
@@ -52,7 +52,6 @@ void _Die(char *file, int line);
os_stack_t *os_arch_task_stack_init(struct os_task *, os_stack_t *, int);
void os_arch_ctx_sw(struct os_task *);
-void os_arch_ctx_sw_isr(struct os_task *);
os_sr_t os_arch_save_sr(void);
void os_arch_restore_sr(os_sr_t sr);
os_error_t os_arch_os_init(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/include/os/os_eventq.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_eventq.h b/libs/os/include/os/os_eventq.h
index e2b0a3d..2111373 100644
--- a/libs/os/include/os/os_eventq.h
+++ b/libs/os/include/os/os_eventq.h
@@ -41,7 +41,6 @@ struct os_eventq {
};
void os_eventq_init(struct os_eventq *);
-void os_eventq_put2(struct os_eventq *, struct os_event *, int);
void os_eventq_put(struct os_eventq *, struct os_event *);
struct os_event *os_eventq_get(struct os_eventq *);
void os_eventq_remove(struct os_eventq *, struct os_event *);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/include/os/os_sched.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_sched.h b/libs/os/include/os/os_sched.h
index ebd7eb5..1d1ba31 100644
--- a/libs/os/include/os/os_sched.h
+++ b/libs/os/include/os/os_sched.h
@@ -26,7 +26,7 @@ void os_sched_ctx_sw_hook(struct os_task *);
struct os_task *os_sched_get_current_task(void);
void os_sched_set_current_task(struct os_task *);
struct os_task *os_sched_next_task(void);
-void os_sched(struct os_task *, int);
+void os_sched(struct os_task *);
void os_sched_os_timer_exp(void);
os_error_t os_sched_insert(struct os_task *);
int os_sched_sleep(struct os_task *, os_time_t nticks);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/arch/cortex_m0/os_arch_arm.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/cortex_m0/os_arch_arm.c b/libs/os/src/arch/cortex_m0/os_arch_arm.c
index ce5efd5..199d0a7 100755
--- a/libs/os/src/arch/cortex_m0/os_arch_arm.c
+++ b/libs/os/src/arch/cortex_m0/os_arch_arm.c
@@ -107,7 +107,7 @@ timer_handler(void)
os_time_tick();
os_callout_tick();
os_sched_os_timer_exp();
- os_sched(NULL, 1);
+ os_sched(NULL);
}
void
@@ -119,15 +119,6 @@ os_arch_ctx_sw(struct os_task *t)
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
}
-void
-os_arch_ctx_sw_isr(struct os_task *t)
-{
- os_sched_ctx_sw_hook(t);
-
- /* Set PendSV interrupt pending bit to force context switch */
- SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
-}
-
os_sr_t
os_arch_save_sr(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/arch/cortex_m4/os_arch_arm.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/cortex_m4/os_arch_arm.c b/libs/os/src/arch/cortex_m4/os_arch_arm.c
index 439d7e7..0e6a22a 100755
--- a/libs/os/src/arch/cortex_m4/os_arch_arm.c
+++ b/libs/os/src/arch/cortex_m4/os_arch_arm.c
@@ -96,7 +96,7 @@ timer_handler(void)
os_time_tick();
os_callout_tick();
os_sched_os_timer_exp();
- os_sched(NULL, 1);
+ os_sched(NULL);
}
void
@@ -108,15 +108,6 @@ os_arch_ctx_sw(struct os_task *t)
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
}
-void
-os_arch_ctx_sw_isr(struct os_task *t)
-{
- os_sched_ctx_sw_hook(t);
-
- /* Set PendSV interrupt pending bit to force context switch */
- SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
-}
-
os_sr_t
os_arch_save_sr(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/arch/sim/os_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/os/src/arch/sim/os_arch_sim.c b/libs/os/src/arch/sim/os_arch_sim.c
index 9e08ea1..a0a06d9 100644
--- a/libs/os/src/arch/sim/os_arch_sim.c
+++ b/libs/os/src/arch/sim/os_arch_sim.c
@@ -124,12 +124,6 @@ os_arch_ctx_sw(struct os_task *next_t)
sim_longjmp(sf->sf_jb, 1);
}
-void
-os_arch_ctx_sw_isr(struct os_task *next_t)
-{
- os_arch_ctx_sw(next_t);
-}
-
/*
* Disable signals and enter a critical section.
*
@@ -264,7 +258,7 @@ timer_handler(int sig)
timersub(&time_now, &time_diff, &time_last);
os_sched_os_timer_exp();
- os_sched(NULL, 1);
+ os_sched(NULL);
}
static void
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/os_callout.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_callout.c b/libs/os/src/os_callout.c
index 5ffcd92..6eb37ae 100644
--- a/libs/os/src/os_callout.c
+++ b/libs/os/src/os_callout.c
@@ -125,7 +125,7 @@ os_callout_tick(void)
OS_EXIT_CRITICAL(sr);
if (c) {
- os_eventq_put2(c->c_evq, &c->c_ev, 1);
+ os_eventq_put(c->c_evq, &c->c_ev);
} else {
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/os_eventq.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_eventq.c b/libs/os/src/os_eventq.c
index e3fe6e5..87085ca 100644
--- a/libs/os/src/os_eventq.c
+++ b/libs/os/src/os_eventq.c
@@ -30,7 +30,7 @@ os_eventq_init(struct os_eventq *evq)
}
void
-os_eventq_put2(struct os_eventq *evq, struct os_event *ev, int isr)
+os_eventq_put(struct os_eventq *evq, struct os_event *ev)
{
int resched;
os_sr_t sr;
@@ -58,16 +58,10 @@ os_eventq_put2(struct os_eventq *evq, struct os_event *ev, int isr)
OS_EXIT_CRITICAL(sr);
if (resched) {
- os_sched(NULL, isr);
+ os_sched(NULL);
}
}
-void
-os_eventq_put(struct os_eventq *evq, struct os_event *ev)
-{
- os_eventq_put2(evq, ev, 0);
-}
-
struct os_event *
os_eventq_get(struct os_eventq *evq)
{
@@ -85,7 +79,7 @@ pull_one:
os_sched_sleep(evq->evq_task, OS_TIMEOUT_NEVER);
OS_EXIT_CRITICAL(sr);
- os_sched(NULL, 0);
+ os_sched(NULL);
OS_ENTER_CRITICAL(sr);
evq->evq_task = NULL;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/os_mutex.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mutex.c b/libs/os/src/os_mutex.c
index b54f7e5..6519292 100644
--- a/libs/os/src/os_mutex.c
+++ b/libs/os/src/os_mutex.c
@@ -122,7 +122,7 @@ os_mutex_release(struct os_mutex *mu)
/* Re-schedule if needed */
if (resched) {
- os_sched(rdy, 0);
+ os_sched(rdy);
}
return OS_OK;
@@ -218,7 +218,7 @@ os_mutex_pend(struct os_mutex *mu, uint32_t timeout)
os_sched_sleep(current, timeout);
OS_EXIT_CRITICAL(sr);
- os_sched(NULL, 0);
+ os_sched(NULL);
OS_ENTER_CRITICAL(sr);
current->t_flags &= ~OS_TASK_FLAG_MUTEX_WAIT;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/os_sched.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_sched.c b/libs/os/src/os_sched.c
index 5ffd14c..fd30a3e 100644
--- a/libs/os/src/os_sched.c
+++ b/libs/os/src/os_sched.c
@@ -124,10 +124,9 @@ os_sched_set_current_task(struct os_task *t)
* list) or will schedule next_t as the task to run.
*
* @param next_t Task to run
- * @param isr Flag denoting whether we are inside an isr (0:no, 1:yes).
*/
void
-os_sched(struct os_task *next_t, int isr)
+os_sched(struct os_task *next_t)
{
os_sr_t sr;
@@ -138,12 +137,7 @@ os_sched(struct os_task *next_t, int isr)
}
if (next_t != g_current_task) {
- if (isr) {
- os_arch_ctx_sw_isr(next_t);
- } else {
- os_arch_ctx_sw(next_t);
- }
-
+ os_arch_ctx_sw(next_t);
}
OS_EXIT_CRITICAL(sr);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/os_sem.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_sem.c b/libs/os/src/os_sem.c
index 0140c53..181e5de 100644
--- a/libs/os/src/os_sem.c
+++ b/libs/os/src/os_sem.c
@@ -106,7 +106,7 @@ os_sem_release(struct os_sem *sem)
/* Re-schedule if needed */
if (resched) {
- os_sched(rdy, 0);
+ os_sched(rdy);
}
return OS_OK;
@@ -195,7 +195,7 @@ os_sem_pend(struct os_sem *sem, uint32_t timeout)
OS_EXIT_CRITICAL(sr);
if (sched) {
- os_sched(NULL, 0);
+ os_sched(NULL);
/* Check if we timed out or got the semaphore */
if (current->t_flags & OS_TASK_FLAG_SEM_WAIT) {
OS_ENTER_CRITICAL(sr);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c6f7543a/libs/os/src/os_time.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_time.c b/libs/os/src/os_time.c
index 1b703e0..fe7de8b 100644
--- a/libs/os/src/os_time.c
+++ b/libs/os/src/os_time.c
@@ -93,7 +93,7 @@ os_time_delay(int32_t osticks)
OS_ENTER_CRITICAL(sr);
os_sched_sleep(os_sched_get_current_task(), (os_time_t)osticks);
OS_EXIT_CRITICAL(sr);
- os_sched(NULL, 0);
+ os_sched(NULL);
}
}
[16/16] incubator-mynewt-larva git commit: Merge delveop into master
Merge branch 'develop' of
https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
Posted by we...@apache.org.
Merge delveop into master
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/063324d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/063324d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/063324d3
Branch: refs/heads/master
Commit: 063324d365915cbee9a220d2a4775740ac3b35bb
Parents: faa7814 c6f7543
Author: wes3 <wi...@micosa.io>
Authored: Tue Mar 8 14:15:04 2016 -0800
Committer: wes3 <wi...@micosa.io>
Committed: Tue Mar 8 14:15:04 2016 -0800
----------------------------------------------------------------------
LICENSE | 1 +
compiler/arm-none-eabi-m0/pkg.yml | 2 +-
compiler/arm-none-eabi-m4/pkg.yml | 2 +-
compiler/sim/pkg.yml | 7 +-
libs/os/include/os/arch/cortex_m0/os/os_arch.h | 2 +-
libs/os/include/os/arch/cortex_m4/os/os_arch.h | 2 +-
libs/os/include/os/arch/sim/os/os_arch.h | 4 +-
libs/os/include/os/os_eventq.h | 1 -
libs/os/include/os/os_sched.h | 2 +-
libs/os/src/arch/cortex_m0/os_arch_arm.c | 16 +-
libs/os/src/arch/cortex_m4/os_arch_arm.c | 16 +-
libs/os/src/arch/sim/os_arch_sim.c | 327 +++++++++-----------
libs/os/src/arch/sim/os_arch_stack_frame.s | 71 +++++
libs/os/src/os.c | 1 +
libs/os/src/os_callout.c | 2 +-
libs/os/src/os_eventq.c | 12 +-
libs/os/src/os_mutex.c | 4 +-
libs/os/src/os_sched.c | 15 +-
libs/os/src/os_sem.c | 4 +-
libs/os/src/os_time.c | 2 +-
libs/util/include/util/util.h | 2 +
net/nimble/controller/src/ble_ll_adv.c | 18 +-
net/nimble/controller/src/ble_ll_conn.c | 3 +
net/nimble/controller/src/ble_ll_scan.c | 17 +-
project/bletest/src/main.c | 4 +-
25 files changed, 276 insertions(+), 261 deletions(-)
----------------------------------------------------------------------