-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLauncher.cpp
More file actions
42 lines (34 loc) · 913 Bytes
/
Launcher.cpp
File metadata and controls
42 lines (34 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright (c) 2020 Javier Pimas & LabWare
*
* This program and the accompanying materials are made available under
* the terms of the MIT license, see LICENSE file.
*
* SPDX-License-Identifier: MIT
*/
#include "Launcher.h"
#include "ImageSegment.h"
#include "Util.h"
#include "Runtime.h"
int
Launcher::main(const int argc, const char** argv)
{
if (argc != 2) {
printf("Usage: %s <KERNEL_SEGMENT>\n", argv[0]);
return 1;
}
std::ifstream file(argv[1], std::ifstream::binary);
if (!file) {
printf("No such file: %s\n", argv[1]);
return 1;
}
auto kernel = ImageSegment::load(&file);
return launch(kernel, argc, argv);;
}
int
Launcher::launch(ImageSegment *kernel, const int argc, const char **argv)
{
ASSERT(kernel != nullptr);
auto runtime = (Runtime*)(void*)kernel->header.module->slot(6);
return runtime->init(argc, argv);
}