MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / setupThreadStack

Function setupThreadStack

source/kernel/kprocess.cpp:405–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405static void setupThreadStack(KThread* thread, CPU* cpu, BString programName, const std::vector<BString>& args, const std::vector<BString>& env) {
406 U32 a[MAX_ARG_COUNT] = {};
407 U32 e[MAX_ARG_COUNT] = {};
408
409 cpu->push32(0);
410 cpu->push32(0);
411 cpu->push32(0);
412 writeStackString(thread, cpu, programName.c_str());
413 if (args.size()>MAX_ARG_COUNT)
414 kpanic_fmt("Too many args: %d is max", MAX_ARG_COUNT);
415 if (env.size()>MAX_ARG_COUNT)
416 kpanic_fmt("Too many env: %d is max", MAX_ARG_COUNT);
417 //klog("env");
418 for (size_t i=0;i<env.size();i++) {
419 writeStackString(thread, cpu, env[i].c_str());
420 if (strncmp(env[i].c_str(), "PATH=", 5)==0) {
421 env[i].substr(5).split(':', cpu->thread->process->path);
422 }
423 //klog(" %s", env[i]);
424 e[i]=ESP;
425 }
426 for (S32 i=(S32)args.size()-1;i>=0;i--) {
427 writeStackString(thread, cpu, args[i].c_str());
428 a[i]=ESP;
429 }
430
431 pushThreadStack(thread, cpu, (U32)args.size(), a, (U32)env.size(), e);
432}
433
434U32 KProcess::getNextFileDescriptorHandle(int after) {
435 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(fdsMutex);

Callers 2

startProcessMethod · 0.85
execveMethod · 0.85

Calls 8

writeStackStringFunction · 0.85
kpanic_fmtFunction · 0.85
pushThreadStackFunction · 0.85
substrMethod · 0.80
push32Method · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected