ImplNodeEx::ImplNodeEx(const ustring& name) : name_(name) { LogTraceObj(); LogTrace2(L"('%s', '%s')", this->name(), parent_ ? parent_->name() : L""); memory::zero(data_); update(); }
void angel_SelectNextTask(void) { angel_TaskQueueItem *tqi; /* Find the task with the highest priority which is not blocked */ for (tqi = angel_TaskQueueHead; tqi != NULL; tqi = tqi->next) { /* Ignore this task if it is the application or an Appl Callback * and the Application is blocked */ if (angel_ApplicationBlocked && (tqi->pri == TP_Application || tqi->pri == TP_ApplCallBack)) { LogTrace2("SNT-SKIP-t%d-p%d ", tqi->index, tqi->pri); continue; } /* Otherwise this is the highest priority task so execute it ! */ #ifdef DEBUG_TASKS LogInfo(LOG_SERLOCK, ("SelectNewTask: Selecting pc %x - t%d - p%d - n%d ", tqi->rb.r[15], tqi->index, tqi->pri, tqi->new_task)); #endif angel_LastExecutedTaskPriority = tqi->pri; angel_FreeToPool(tqi->index); #if 0 if (tqi->pri == TP_Application) { int i; LogWarning(LOG_SERLOCK, ( "Application starting:\n")); for (i = 0; i < 16; i++) { LogWarning(LOG_SERLOCK, ( "%8X ", tqi->rb.r[i])); } LogWarning(LOG_SERLOCK, ( "CPSR=%8X\n", tqi->rb.cpsr)); } #endif /* if it's not an interrupted thread, we need to set its environment */ if (tqi->new_task) angel_SetUpTaskEnvironment(&(tqi->rb), angel_LastExecutedTaskPriority); else LogTrace("\n"); angel_StartTask(&(tqi->rb)); /* doesn't return! */ } if (tqi == NULL) { LogTrace("SNT-IDLE "); angel_LastExecutedTaskPriority = TP_IdleLoop; angel_IdleLoop(); } }
ImplNodeEx::ImplNodeEx(const ustring& name, const Node& parent) : name_(name) , parent_(parent) { LogTraceObj(); LogTrace2(L"('%s')", this->name()); memory::zero(data_); update(); }
const PluginPanelItem* FacadeImpl::operator [](size_t index) const { size_t m_ppiSize = psi().PanelControl(m_hndl, FCTL_GETPANELITEM, index, nullptr); LogTrace2(L"size: %Iu\n", m_ppiSize); m_ppi = static_cast<decltype(m_ppi)>(HostRealloc(heap_type, m_ppi, m_ppiSize)); FarGetPluginPanelItem gpi = {sizeof(gpi), m_ppiSize, m_ppi}; psi().PanelControl(m_hndl, FCTL_GETPANELITEM, index, &gpi); LogTrace(L"[%Iu] -> %p\n", index, m_ppi); return m_ppi; }
ImplNodeEx::ImplNodeEx(const fsys::IFindStat& stat, const Node& parent) noexcept : name_(stat.name()) , parent_(parent) { LogTraceObj(); LogTrace2(L"('%s', '%s')", this->name(), parent ? parent->name() : L""); memory::zero(data_); data_.dwFileAttributes = static_cast<decltype(data_.dwFileAttributes)>(stat.attr()); data_.ftCreationTime.dwHighDateTime = static_cast<decltype(data_.ftCreationTime.dwHighDateTime)>(high_part_64(stat.ctime())); data_.ftCreationTime.dwLowDateTime = static_cast<decltype(data_.ftCreationTime.dwLowDateTime)>(low_part_64(stat.ctime())); data_.ftLastAccessTime.dwHighDateTime = static_cast<decltype(data_.ftLastAccessTime.dwHighDateTime)>(high_part_64(stat.atime())); data_.ftLastAccessTime.dwLowDateTime = static_cast<decltype(data_.ftLastAccessTime.dwLowDateTime)>(low_part_64(stat.atime())); data_.ftLastWriteTime.dwHighDateTime = static_cast<decltype(data_.ftLastWriteTime.dwHighDateTime)>(high_part_64(stat.mtime())); data_.ftLastWriteTime.dwLowDateTime = static_cast<decltype(data_.ftLastWriteTime.dwLowDateTime)>(low_part_64(stat.mtime())); data_.nFileSizeHigh = static_cast<decltype(data_.nFileSizeHigh)>(high_part_64(stat.size())); data_.nFileSizeLow = static_cast<decltype(data_.nFileSizeLow)>(low_part_64(stat.size())); }
/* * This routine looks for an interrupted queued task at the given * priority */ static angel_RegBlock * angel_AccessQueuedRegBlock(angel_TaskPriority pri) { angel_TaskQueueItem *tqi; /* Find a task with the required priority, not marked as new */ for (tqi = angel_TaskQueueHead; (tqi != NULL) && !((tqi->pri == pri) && (!tqi->new_task)); ) { tqi = tqi->next; } if (tqi == NULL) { LogTrace1("SAccessQueue: p%d-NT ", pri); return NULL; } else { LogTrace2("SAccessQueue: p%d-t%d ", pri, tqi->index); return &(tqi->rb); } }
Node node(const fsys::IFindStat& stat, const Node& parent) { LogTrace2(L"('%s', '%s')", stat.name(), parent ? parent->name() : L""); return simstd::make_shared<ImplNodeEx>(stat, parent); }
Node node(const ustring& name, const Node& parent) { LogTrace2(L"('%s', '%s')", name.c_str(), parent ? parent->name() : L""); return simstd::make_shared<ImplNodeEx>(name, parent); }
Node node(const ustring& name) { LogTrace2(L"('%s')", name.c_str()); return simstd::make_shared<ImplNodeEx>(name); }
void remove(const wchar_t* path) { LogTrace2(L"('%s')", path); CheckApi(fsys::file::remove(path)); }
void create(const wchar_t* path, LPSECURITY_ATTRIBUTES sa) { LogTrace2(L"('%s')", path); memory::auto_close<HANDLE> file(CheckHandleErr(::CreateFileW(path, 0, 0, sa, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr))); }
static void angel_SetUpTaskEnvironment(angel_RegBlock * rb, angel_TaskPriority pri) { angel_RegBlock *env_rb; /* LogInfo(LOG_SERLOCK, ("SetUpTaskEnvironment: p%d\n", pri)); */ switch (pri) { case TP_ApplCallBack: { LogInfo(LOG_SERLOCK, ( "SetUpTask: ApplCallBack\n")); env_rb = Angel_AccessApplicationRegBlock(); rb->r[10] = env_rb->r[10]; /* Copy sl from Application */ rb->r[13] = env_rb->r[13]; /* Copy sp from Application */ rb->r[11] = 0; /* fp = 0 */ rb->r[14] = (unsigned)angel_NextTask; rb->cpsr = USRmode; break; } case TP_AngelCallBack: { angel_TaskQueueItem *tqi; LogInfo(LOG_SERLOCK, ( "SetUpTask: AngelCallBack\n")); /* * Find a task with priority AngelCallBack or AngelInit (used * when initialising) which is not marked as new */ tqi = angel_TaskQueueHead; while ((tqi != NULL) && ((tqi->pri != TP_AngelInit && tqi->pri != TP_AngelCallBack) || tqi->new_task)) { tqi = tqi->next; } if (tqi != NULL) { /* There is at least one such task queued */ env_rb = &(tqi->rb); LogInfo(LOG_SERLOCK, ("... found 1st task sp=%X, sl=%X, pc=%X, pri=%d\n", env_rb->r[13], env_rb->r[10], env_rb->r[15], tqi->pri)); /* * Look for other (non new) tasks with a lower sp with the same * priority. * * XXX * * This code relies upon: * * 1) The Task Queue being ordered on priority (highest first) * * 2) Queued processes of priority TP_AngelCallBack using lower * regions of the Angel stack than processes of priority * TP_AngelInit. * * Fortunately, both of these conditions are true. */ do { tqi = tqi->next; if (tqi == NULL || (tqi->pri != TP_AngelInit && tqi->pri != TP_AngelCallBack)) break; if (tqi->new_task) continue; LogInfo(LOG_SERLOCK, ("... found nth task sp=%X, sl=%X, pc=%x, pri=%d\n", tqi->rb.r[13], tqi->rb.r[10], tqi->rb.r[15], tqi->pri)); if (tqi->rb.r[13] >= env_rb->r[13]) continue; env_rb = &(tqi->rb); } while (TRUE); LogInfo(LOG_SERLOCK, ( "stack being stolen for process @%X\n", rb->r[15])); /* * Now we know that env_rb hold the regs of the task of this priority * with the lowest sp. */ env_rb->r[10] = env_rb->r[13] - Angel_AngelStackFreeSpace; rb->r[13] = env_rb->r[10]; } else { /* There were no tasks of the sought priority */ LogInfo(LOG_SERLOCK, ( "...no task found\n")); rb->r[13] = Angel_StackBase + Angel_AngelStackOffset; } LogTrace2("SUE-sl%8X-sp%8X ", rb->r[10], rb->r[13]); rb->r[10] = Angel_StackBase + Angel_AngelStackLimitOffset; rb->r[11] = 0; /* fp = 0 */ rb->r[14] = (unsigned)angel_NextTask; rb->cpsr = USRmode; break; } case TP_AngelWantLock: { /* LogInfo(LOG_SERLOCK, ( "SetUpTask: AngelWantLock\n")); */ rb->r[10] = Angel_StackBase + Angel_SVCStackLimitOffset; rb->r[13] = Angel_StackBase + Angel_SVCStackOffset; rb->r[11] = 0; /* fp = 0 */ rb->r[14] = (unsigned)angel_NextTask; rb->cpsr = SVCmode; break; } default: /* * Never set up anything for TP_Application, TP_IdleLoop or * TP_AngelInit */ break; } }