OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #if defined(FLETCH_TARGET_OS_CMSIS) | 5 #if defined(DARTINO_TARGET_OS_CMSIS) |
6 | 6 |
7 #include <cmsis_os.h> | 7 #include <cmsis_os.h> |
8 | 8 |
9 #include "src/vm/event_handler.h" | 9 #include "src/vm/event_handler.h" |
10 #include "src/vm/object.h" | 10 #include "src/vm/object.h" |
11 #include "src/vm/port.h" | 11 #include "src/vm/port.h" |
12 #include "src/vm/process.h" | 12 #include "src/vm/process.h" |
13 #include "src/shared/platform.h" | 13 #include "src/shared/platform.h" |
14 | 14 |
15 namespace fletch { | 15 namespace dartino { |
16 | 16 |
17 const uint32_t kInterruptPortId = 0; | 17 const uint32_t kInterruptPortId = 0; |
18 | 18 |
19 class PortMapping { | 19 class PortMapping { |
20 public: | 20 public: |
21 PortMapping() : mapping() {} | 21 PortMapping() : mapping() {} |
22 | 22 |
23 void SetPort(uint32_t port_id, Port *port) { | 23 void SetPort(uint32_t port_id, Port *port) { |
24 Port *existing = mapping[port_id]; | 24 Port *existing = mapping[port_id]; |
25 if (existing != NULL) FATAL("Already listening to port"); | 25 if (existing != NULL) FATAL("Already listening to port"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 int port_id = Smi::cast(id)->value(); | 57 int port_id = Smi::cast(id)->value(); |
58 | 58 |
59 ScopedMonitorLock locker(monitor_); | 59 ScopedMonitorLock locker(monitor_); |
60 | 60 |
61 reinterpret_cast<PortMapping*>(data_)->SetPort(port_id, port); | 61 reinterpret_cast<PortMapping*>(data_)->SetPort(port_id, port); |
62 port->IncrementRef(); | 62 port->IncrementRef(); |
63 return process->program()->null_object(); | 63 return process->program()->null_object(); |
64 } | 64 } |
65 | 65 |
66 void EventHandler::Run() { | 66 void EventHandler::Run() { |
67 osMailQId queue = GetFletchMailQ(); | 67 osMailQId queue = GetDartinoMailQ(); |
68 while (true) { | 68 while (true) { |
69 int64 next_timeout; | 69 int64 next_timeout; |
70 { | 70 { |
71 ScopedMonitorLock locker(monitor_); | 71 ScopedMonitorLock locker(monitor_); |
72 next_timeout = next_timeout_; | 72 next_timeout = next_timeout_; |
73 } | 73 } |
74 | 74 |
75 if (next_timeout == INT64_MAX) { | 75 if (next_timeout == INT64_MAX) { |
76 next_timeout = -1; | 76 next_timeout = -1; |
77 } else { | 77 } else { |
(...skipping 26 matching lines...) Expand all Loading... |
104 } else { | 104 } else { |
105 reinterpret_cast<PortMapping*>(data_)->RemovePort(port_id); | 105 reinterpret_cast<PortMapping*>(data_)->RemovePort(port_id); |
106 Send(port, value, true); | 106 Send(port, value, true); |
107 } | 107 } |
108 } | 108 } |
109 osMailFree(queue, reinterpret_cast<void*>(message)); | 109 osMailFree(queue, reinterpret_cast<void*>(message)); |
110 } | 110 } |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 } // namespace fletch | 114 } // namespace dartino |
115 | 115 |
116 #endif // defined(FLETCH_TARGET_OS_CMSIS) | 116 #endif // defined(DARTINO_TARGET_OS_CMSIS) |
OLD | NEW |