paul@308 | 1 | /* |
paul@308 | 2 | * Support for executing code in new tasks and threads. |
paul@308 | 3 | * |
paul@308 | 4 | * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk> |
paul@308 | 5 | * |
paul@308 | 6 | * This program is free software; you can redistribute it and/or |
paul@308 | 7 | * modify it under the terms of the GNU General Public License as |
paul@308 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@308 | 9 | * the License, or (at your option) any later version. |
paul@308 | 10 | * |
paul@308 | 11 | * This program is distributed in the hope that it will be useful, |
paul@308 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@308 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@308 | 14 | * GNU General Public License for more details. |
paul@308 | 15 | * |
paul@308 | 16 | * You should have received a copy of the GNU General Public License |
paul@308 | 17 | * along with this program; if not, write to the Free Software |
paul@308 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@308 | 19 | * Boston, MA 02110-1301, USA |
paul@308 | 20 | */ |
paul@308 | 21 | |
paul@308 | 22 | #include <l4/re/env.h> |
paul@322 | 23 | #include <l4/re/l4aux.h> |
paul@308 | 24 | #include <l4/sys/err.h> |
paul@312 | 25 | #include <l4/util/elf.h> |
paul@312 | 26 | #include <l4/util/util.h> |
paul@308 | 27 | |
paul@324 | 28 | #include <exec/process.h> |
paul@308 | 29 | #include <fsclient/client.h> |
paul@308 | 30 | #include <ipc/mem_ipc.h> |
paul@308 | 31 | #include <ipc/server.h> |
paul@311 | 32 | #include <mem/memory_utils.h> |
paul@308 | 33 | #include <systypes/fcntl.h> |
paul@308 | 34 | |
paul@312 | 35 | #include <map> |
paul@312 | 36 | |
paul@308 | 37 | #include <stdio.h> |
paul@308 | 38 | #include <stdlib.h> |
paul@308 | 39 | #include <string.h> |
paul@308 | 40 | |
paul@308 | 41 | #include <pthread-l4.h> |
paul@308 | 42 | #include <pthread.h> |
paul@308 | 43 | |
paul@312 | 44 | #include "pager_object_interface.h" |
paul@312 | 45 | #include "pager_object_server.h" |
paul@308 | 46 | |
paul@308 | 47 | |
paul@308 | 48 | |
paul@312 | 49 | /* A simple system pager also acting as a region mapper. */ |
paul@312 | 50 | |
paul@320 | 51 | typedef std::map<l4_addr_t, MappedRegion> MappedRegions; |
paul@316 | 52 | |
paul@312 | 53 | class ExecPager : public PagerObject |
paul@312 | 54 | { |
paul@312 | 55 | protected: |
paul@320 | 56 | MappedRegions _regions; |
paul@312 | 57 | |
paul@312 | 58 | public: |
paul@320 | 59 | virtual void add(MappedRegion region) |
paul@312 | 60 | { |
paul@312 | 61 | _regions[region.map_start] = region; |
paul@312 | 62 | } |
paul@312 | 63 | |
paul@312 | 64 | /* Notification methods. */ |
paul@308 | 65 | |
paul@308 | 66 | virtual long exception(l4_exc_regs_t regs, |
paul@308 | 67 | l4_snd_fpage_t *region); |
paul@308 | 68 | |
paul@308 | 69 | virtual long page_fault(l4_umword_t pfa, l4_umword_t pc, |
paul@308 | 70 | l4_snd_fpage_t *region); |
paul@312 | 71 | |
paul@312 | 72 | /* Region manager/mapper methods. */ |
paul@312 | 73 | |
paul@312 | 74 | virtual long attach(address_t *start, offset_t size, map_flags_t flags, |
paul@312 | 75 | l4_cap_idx_t ds, address_t offset, unsigned char align); |
paul@312 | 76 | |
paul@308 | 77 | }; |
paul@308 | 78 | |
paul@312 | 79 | /* Handle a general exception. */ |
paul@312 | 80 | |
paul@308 | 81 | long ExecPager::exception(l4_exc_regs_t regs, l4_snd_fpage_t *region) |
paul@308 | 82 | { |
paul@308 | 83 | (void) region; |
paul@308 | 84 | |
paul@308 | 85 | printf("exception(...) -> pfa = %lx, pc = %lx\n", l4_utcb_exc_pfa(®s), l4_utcb_exc_pc(®s)); |
paul@312 | 86 | |
paul@312 | 87 | printf("r15 = %lx\n", regs.r15); |
paul@312 | 88 | printf("r14 = %lx\n", regs.r14); |
paul@312 | 89 | printf("r13 = %lx\n", regs.r13); |
paul@312 | 90 | printf("r12 = %lx\n", regs.r12); |
paul@312 | 91 | printf("r11 = %lx\n", regs.r11); |
paul@312 | 92 | printf("r10 = %lx\n", regs.r10); |
paul@312 | 93 | printf("r9 = %lx\n", regs.r9); |
paul@312 | 94 | printf("r8 = %lx\n", regs.r8); |
paul@312 | 95 | printf("rdi = %lx\n", regs.rdi); |
paul@312 | 96 | printf("rsi = %lx\n", regs.rsi); |
paul@312 | 97 | printf("rbp = %lx\n", regs.rbp); |
paul@312 | 98 | printf("pfa = %lx\n", regs.pfa); |
paul@312 | 99 | printf("rbx = %lx\n", regs.rbx); |
paul@312 | 100 | printf("rdx = %lx\n", regs.rdx); |
paul@312 | 101 | printf("rcx = %lx\n", regs.rcx); |
paul@312 | 102 | printf("rax = %lx\n", regs.rax); |
paul@312 | 103 | printf("trapno = %lx\n", regs.trapno); |
paul@312 | 104 | printf("err = %lx\n", regs.err); |
paul@312 | 105 | printf("ip = %lx\n", regs.ip); |
paul@312 | 106 | printf("flags = %lx\n", regs.flags); |
paul@312 | 107 | printf("sp = %lx\n", regs.sp); |
paul@312 | 108 | printf("ss = %lx\n", regs.ss); |
paul@312 | 109 | printf("fs_base = %lx\n", regs.fs_base); |
paul@312 | 110 | printf("gs_base = %lx\n", regs.gs_base); |
paul@312 | 111 | |
paul@308 | 112 | return L4_EOK; |
paul@308 | 113 | } |
paul@308 | 114 | |
paul@315 | 115 | #define DEBUG 0 |
paul@315 | 116 | |
paul@312 | 117 | /* Handle a page fault using any configured regions. */ |
paul@312 | 118 | |
paul@308 | 119 | long ExecPager::page_fault(l4_umword_t pfa, l4_umword_t pc, l4_snd_fpage_t *region) |
paul@308 | 120 | { |
paul@308 | 121 | l4_umword_t addr = pfa & ~7UL, flags = pfa & 7; |
paul@308 | 122 | |
paul@315 | 123 | #if DEBUG |
paul@312 | 124 | printf("page_fault(%lx, %lx) -> %lx (%lx) -> ", pfa, pc, addr, flags); |
paul@312 | 125 | #endif |
paul@312 | 126 | |
paul@320 | 127 | MappedRegions::iterator it = _regions.upper_bound(addr); |
paul@312 | 128 | |
paul@312 | 129 | if (it != _regions.begin()) |
paul@312 | 130 | it--; |
paul@312 | 131 | else |
paul@312 | 132 | { |
paul@312 | 133 | printf("not mapped!\n"); |
paul@312 | 134 | return -L4_ENOMEM; |
paul@312 | 135 | } |
paul@312 | 136 | |
paul@320 | 137 | MappedRegion &r = it->second; |
paul@308 | 138 | |
paul@312 | 139 | if ((addr >= r.map_start) && (addr < r.map_start + (1UL << r.log2size))) |
paul@308 | 140 | { |
paul@312 | 141 | l4_addr_t page_addr = trunc(addr, L4_PAGESIZE); |
paul@312 | 142 | |
paul@312 | 143 | region->fpage = l4_fpage(r.start + (page_addr - r.map_start), L4_PAGESHIFT, r.flags); |
paul@312 | 144 | region->snd_base = page_addr; |
paul@312 | 145 | |
paul@315 | 146 | #if DEBUG |
paul@312 | 147 | printf("%lx...%lx from %lx...%lx size %d rights %x\n", |
paul@312 | 148 | r.map_start, region->snd_base, |
paul@312 | 149 | r.start, l4_fpage_memaddr(region->fpage), |
paul@312 | 150 | l4_fpage_size(region->fpage), |
paul@312 | 151 | l4_fpage_rights(region->fpage)); |
paul@312 | 152 | printf("%lx -> ", addr); |
paul@312 | 153 | |
paul@312 | 154 | for (unsigned int i = 0; i < sizeof(l4_umword_t); i++) |
paul@312 | 155 | printf("%02x", *((unsigned char *)(r.start + (addr - r.map_start) + i))); |
paul@312 | 156 | |
paul@312 | 157 | printf("\n"); |
paul@312 | 158 | #endif |
paul@308 | 159 | |
paul@308 | 160 | return L4_EOK; |
paul@308 | 161 | } |
paul@308 | 162 | |
paul@315 | 163 | #if DEBUG |
paul@312 | 164 | printf("not mapped!\n"); |
paul@312 | 165 | #endif |
paul@312 | 166 | |
paul@308 | 167 | return -L4_ENOMEM; |
paul@308 | 168 | } |
paul@308 | 169 | |
paul@312 | 170 | /* Attach a region for provision when page faults occur. This is required in |
paul@312 | 171 | the initialisation of a program by the C library which requires a region |
paul@312 | 172 | mapper. */ |
paul@312 | 173 | |
paul@312 | 174 | long ExecPager::attach(address_t *start, offset_t size, map_flags_t flags, |
paul@312 | 175 | l4_cap_idx_t ds, address_t offset, unsigned char align) |
paul@312 | 176 | { |
paul@315 | 177 | #if DEBUG |
paul@312 | 178 | printf("attach(%lx, %ld, %lx, ..., %lx, %d)\n", *start, size, flags, offset, align); |
paul@312 | 179 | #endif |
paul@312 | 180 | |
paul@312 | 181 | if (align < L4_PAGESHIFT) |
paul@312 | 182 | align = L4_PAGESHIFT; |
paul@312 | 183 | |
paul@312 | 184 | offset_t increment = 1UL << align; |
paul@312 | 185 | offset_t region_size = round(size, increment); |
paul@312 | 186 | |
paul@312 | 187 | /* Either attempt to find an address for the specified region, starting from |
paul@312 | 188 | any indicated address. */ |
paul@312 | 189 | |
paul@312 | 190 | if (flags & L4RE_RM_F_SEARCH_ADDR) |
paul@312 | 191 | { |
paul@312 | 192 | address_t region_start = trunc(*start, increment); |
paul@320 | 193 | MappedRegions::iterator it = _regions.upper_bound(*start); |
paul@312 | 194 | |
paul@312 | 195 | if (!region_start) |
paul@312 | 196 | region_start += increment; |
paul@312 | 197 | |
paul@315 | 198 | #if DEBUG |
paul@312 | 199 | printf("-> search from %lx -> %lx...\n", *start, region_start); |
paul@312 | 200 | #endif |
paul@312 | 201 | |
paul@312 | 202 | /* Before last known region. */ |
paul@312 | 203 | |
paul@312 | 204 | while (it != _regions.end()) |
paul@312 | 205 | { |
paul@320 | 206 | MappedRegions::iterator next = it; |
paul@320 | 207 | MappedRegion &r = it->second; |
paul@312 | 208 | address_t start_limit; |
paul@312 | 209 | address_t end_limit = r.map_start; |
paul@312 | 210 | |
paul@312 | 211 | /* Consider any preceding region. If no such region exists, choose an |
paul@312 | 212 | address at the start of memory. */ |
paul@312 | 213 | |
paul@312 | 214 | if (it == _regions.begin()) |
paul@312 | 215 | start_limit = L4_PAGESIZE; |
paul@312 | 216 | else |
paul@312 | 217 | { |
paul@312 | 218 | it--; |
paul@320 | 219 | MappedRegion &pr = it->second; |
paul@312 | 220 | start_limit = pr.map_start + (1UL << pr.log2size); |
paul@312 | 221 | it = next; |
paul@312 | 222 | } |
paul@312 | 223 | |
paul@312 | 224 | /* Test against the limits. */ |
paul@312 | 225 | |
paul@312 | 226 | if (region_start < start_limit) |
paul@312 | 227 | region_start = round(start_limit, increment); |
paul@312 | 228 | |
paul@312 | 229 | /* Investigate subsequent regions if not enough space exists between the |
paul@312 | 230 | preceding region (or start of memory) and the current region. */ |
paul@312 | 231 | |
paul@312 | 232 | if ((region_start + region_size) > end_limit) |
paul@312 | 233 | { |
paul@312 | 234 | it++; |
paul@312 | 235 | if (it == _regions.end()) |
paul@312 | 236 | return -L4_ENOMEM; |
paul@312 | 237 | } |
paul@312 | 238 | else |
paul@312 | 239 | break; |
paul@312 | 240 | } |
paul@312 | 241 | |
paul@312 | 242 | /* Attach the provided dataspace. |
paul@312 | 243 | NOTE: This is only done in this implementation to support the paging |
paul@312 | 244 | mechanism. In a region mapper residing within the actual task, the |
paul@312 | 245 | dataspace's map operation would be invoked to obtain mappings. */ |
paul@312 | 246 | |
paul@312 | 247 | l4_addr_t ds_start; |
paul@312 | 248 | |
paul@312 | 249 | long err = ipc_attach_dataspace(ds, size, (void **) &ds_start); |
paul@312 | 250 | |
paul@312 | 251 | if (err) |
paul@312 | 252 | return err; |
paul@312 | 253 | |
paul@312 | 254 | l4_touch_rw((const void *) ds_start, size); |
paul@312 | 255 | |
paul@315 | 256 | #if DEBUG |
paul@312 | 257 | printf("-> added region for %lx size %ld (%d)\n", region_start, region_size, page_order(region_size)); |
paul@312 | 258 | #endif |
paul@312 | 259 | |
paul@320 | 260 | add(MappedRegion(ds_start, page_order(region_size), flags & L4RE_DS_F_RIGHTS_MASK, region_start)); |
paul@312 | 261 | |
paul@312 | 262 | *start = region_start; |
paul@312 | 263 | return L4_EOK; |
paul@312 | 264 | } |
paul@312 | 265 | |
paul@312 | 266 | /* Or attempt to add the specified region at a specific address. */ |
paul@312 | 267 | |
paul@312 | 268 | else |
paul@312 | 269 | { |
paul@312 | 270 | // NOTE: To be implemented. |
paul@312 | 271 | |
paul@312 | 272 | return -L4_ENOMEM; |
paul@312 | 273 | } |
paul@312 | 274 | } |
paul@312 | 275 | |
paul@308 | 276 | |
paul@308 | 277 | |
paul@323 | 278 | class PayloadBase |
paul@323 | 279 | { |
paul@323 | 280 | public: |
paul@323 | 281 | virtual l4_addr_t entry_point() = 0; |
paul@323 | 282 | virtual offset_t header_size() = 0; |
paul@323 | 283 | }; |
paul@323 | 284 | |
paul@323 | 285 | template <typename HEADER> |
paul@323 | 286 | class Payload : public PayloadBase |
paul@323 | 287 | { |
paul@323 | 288 | protected: |
paul@323 | 289 | HEADER *_header; |
paul@323 | 290 | |
paul@323 | 291 | public: |
paul@323 | 292 | explicit Payload(HEADER *header) |
paul@323 | 293 | : _header(header) |
paul@323 | 294 | { |
paul@323 | 295 | } |
paul@323 | 296 | |
paul@323 | 297 | l4_addr_t entry_point() |
paul@323 | 298 | { |
paul@323 | 299 | return _header->e_entry; |
paul@323 | 300 | } |
paul@323 | 301 | |
paul@323 | 302 | offset_t header_size() |
paul@323 | 303 | { |
paul@323 | 304 | return sizeof(HEADER); |
paul@323 | 305 | } |
paul@323 | 306 | }; |
paul@323 | 307 | |
paul@323 | 308 | static PayloadBase *get_payload(char *buf) |
paul@323 | 309 | { |
paul@323 | 310 | switch (buf[EI_CLASS]) |
paul@323 | 311 | { |
paul@323 | 312 | case (char) 1: |
paul@323 | 313 | return new Payload<Elf32_Ehdr>((Elf32_Ehdr *) buf); |
paul@323 | 314 | case (char) 2: |
paul@323 | 315 | return new Payload<Elf64_Ehdr>((Elf64_Ehdr *) buf); |
paul@323 | 316 | default: |
paul@323 | 317 | return NULL; |
paul@323 | 318 | } |
paul@323 | 319 | } |
paul@323 | 320 | |
paul@323 | 321 | |
paul@323 | 322 | |
paul@308 | 323 | static ExecPager exec_pager; |
paul@308 | 324 | |
paul@312 | 325 | static void init_pager(ipc_server_config_type *config) |
paul@308 | 326 | { |
paul@308 | 327 | ipc_server_init_config(config); |
paul@308 | 328 | |
paul@312 | 329 | config->expected_items = PagerObject_expected_items; |
paul@312 | 330 | config->handler = (ipc_server_handler_type) handle_PagerObject; |
paul@312 | 331 | config->handler_obj = static_cast<PagerObject *>(&exec_pager); |
paul@308 | 332 | } |
paul@308 | 333 | |
paul@308 | 334 | static long start_pager(ipc_server_config_type *config, pthread_t thread) |
paul@308 | 335 | { |
paul@308 | 336 | config->config_thread = 1; |
paul@308 | 337 | config->thread = pthread_l4_cap(thread); |
paul@308 | 338 | |
paul@308 | 339 | printf("Starting pager thread...\n"); |
paul@308 | 340 | return ipc_server_start_config(config); |
paul@308 | 341 | } |
paul@308 | 342 | |
paul@308 | 343 | |
paul@308 | 344 | |
paul@308 | 345 | int main(int argc, char *argv[]) |
paul@308 | 346 | { |
paul@308 | 347 | long err; |
paul@308 | 348 | |
paul@308 | 349 | if (argc < 2) |
paul@308 | 350 | { |
paul@308 | 351 | printf("Need a program to run.\n"); |
paul@308 | 352 | return 1; |
paul@308 | 353 | } |
paul@308 | 354 | |
paul@308 | 355 | /* Obtain the payload as a dataspace. */ |
paul@308 | 356 | |
paul@308 | 357 | file_t *file = client_open(argv[1], O_RDONLY); |
paul@308 | 358 | |
paul@308 | 359 | if (file == NULL) |
paul@308 | 360 | { |
paul@308 | 361 | printf("Could not read file: %s\n", argv[1]); |
paul@308 | 362 | return 1; |
paul@308 | 363 | } |
paul@308 | 364 | |
paul@323 | 365 | /* Obtain metadata from the file. */ |
paul@323 | 366 | |
paul@323 | 367 | char buf[4096]; |
paul@323 | 368 | offset_t nread; |
paul@323 | 369 | |
paul@323 | 370 | nread = client_read(file, buf, EI_NIDENT); |
paul@323 | 371 | if ((nread < EI_NIDENT) || memcmp(buf, "\x7f" "ELF", 4)) |
paul@323 | 372 | { |
paul@323 | 373 | printf("Not an ELF payload: %s\n", argv[1]); |
paul@323 | 374 | return 1; |
paul@323 | 375 | } |
paul@323 | 376 | |
paul@323 | 377 | PayloadBase *payload = get_payload(buf); |
paul@323 | 378 | |
paul@323 | 379 | if (payload == NULL) |
paul@323 | 380 | { |
paul@323 | 381 | printf("Unrecognised object size.\n"); |
paul@323 | 382 | return 1; |
paul@323 | 383 | } |
paul@323 | 384 | |
paul@323 | 385 | client_seek(file, 0, SEEK_SET); |
paul@323 | 386 | nread = client_read(file, buf, payload->header_size()); |
paul@323 | 387 | |
paul@323 | 388 | if (nread < payload->header_size()) |
paul@323 | 389 | { |
paul@323 | 390 | printf("Header incomplete.\n"); |
paul@323 | 391 | return 1; |
paul@323 | 392 | } |
paul@323 | 393 | |
paul@323 | 394 | printf("Program start: %lx\n", payload->entry_point()); |
paul@323 | 395 | |
paul@312 | 396 | /* Copy the payload regions to new dataspaces. |
paul@312 | 397 | NOTE: This should be directed by the ELF metadata. */ |
paul@308 | 398 | |
paul@323 | 399 | address_t program_start = payload->entry_point(); |
paul@320 | 400 | offset_t initial_stack_size = 16 * L4_PAGESIZE; |
paul@315 | 401 | |
paul@318 | 402 | Segment program(0x1000000, 0x28326, L4_FPAGE_RWX, 0, 0x28326); |
paul@316 | 403 | Segment data(0x1029360, 0x8068, L4_FPAGE_RW, 0x28360, 0x2058); |
paul@320 | 404 | Segment stack(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW); |
paul@316 | 405 | Segment *segments[] = {&program, &data, &stack, NULL}; |
paul@316 | 406 | Segment **segment; |
paul@316 | 407 | |
paul@316 | 408 | for (segment = segments; *segment != NULL; segment++) |
paul@316 | 409 | { |
paul@316 | 410 | err = (*segment)->allocate(); |
paul@308 | 411 | |
paul@316 | 412 | if (err) |
paul@316 | 413 | { |
paul@316 | 414 | printf("Could not reserve memory.\n"); |
paul@316 | 415 | return 1; |
paul@316 | 416 | } |
paul@308 | 417 | |
paul@316 | 418 | err = (*segment)->fill(file); |
paul@316 | 419 | |
paul@316 | 420 | if (err) |
paul@316 | 421 | { |
paul@316 | 422 | printf("Could not fill segment from file.\n"); |
paul@316 | 423 | return 1; |
paul@316 | 424 | } |
paul@308 | 425 | } |
paul@308 | 426 | |
paul@308 | 427 | /* Start the pager. */ |
paul@308 | 428 | |
paul@308 | 429 | ipc_server_config_type config; |
paul@308 | 430 | pthread_t pager_thread; |
paul@308 | 431 | pthread_attr_t attr; |
paul@308 | 432 | |
paul@308 | 433 | pthread_attr_init(&attr); |
paul@308 | 434 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
paul@308 | 435 | |
paul@312 | 436 | init_pager(&config); |
paul@312 | 437 | |
paul@316 | 438 | for (segment = segments; *segment != NULL; segment++) |
paul@316 | 439 | exec_pager.add((*segment)->region()); |
paul@308 | 440 | |
paul@308 | 441 | err = pthread_create(&pager_thread, &attr, ipc_server_start_mainloop, &config); |
paul@308 | 442 | |
paul@308 | 443 | if (err) |
paul@308 | 444 | { |
paul@308 | 445 | printf("Could not start pager thread.\n"); |
paul@308 | 446 | return 1; |
paul@308 | 447 | } |
paul@308 | 448 | |
paul@308 | 449 | err = start_pager(&config, pager_thread); |
paul@308 | 450 | |
paul@308 | 451 | if (err) |
paul@308 | 452 | { |
paul@308 | 453 | printf("Could not start pager.\n"); |
paul@308 | 454 | return 1; |
paul@308 | 455 | } |
paul@308 | 456 | |
paul@319 | 457 | /* Configure the environment for the task, specifying the pager (and exception |
paul@319 | 458 | handler plus region mapper). */ |
paul@308 | 459 | |
paul@321 | 460 | Process process; |
paul@321 | 461 | |
paul@321 | 462 | err = process.configure(config.server); |
paul@308 | 463 | |
paul@308 | 464 | if (err) |
paul@308 | 465 | { |
paul@321 | 466 | printf("Could not configure task.\n"); |
paul@308 | 467 | return 1; |
paul@308 | 468 | } |
paul@308 | 469 | |
paul@321 | 470 | /* Populate a thread stack with argument and environment details. */ |
paul@321 | 471 | |
paul@321 | 472 | Stack st(stack); |
paul@321 | 473 | |
paul@321 | 474 | /* NOTE: Environment vector is currently not defined. */ |
paul@321 | 475 | |
paul@321 | 476 | char *envp[] = {NULL}; |
paul@321 | 477 | |
paul@321 | 478 | st.populate(argc - 1, argv + 1, envp); |
paul@321 | 479 | |
paul@321 | 480 | /* Start the new thread in the given stack. */ |
paul@308 | 481 | |
paul@308 | 482 | printf("Run thread...\n"); |
paul@308 | 483 | |
paul@321 | 484 | err = process.thread_start(program_start, st); |
paul@308 | 485 | |
paul@308 | 486 | if (err) |
paul@308 | 487 | { |
paul@308 | 488 | printf("Could not run thread.\n"); |
paul@308 | 489 | return 1; |
paul@308 | 490 | } |
paul@308 | 491 | |
paul@308 | 492 | printf("Finished.\n"); |
paul@308 | 493 | while (1); |
paul@308 | 494 | |
paul@308 | 495 | return 0; |
paul@308 | 496 | } |
paul@308 | 497 | |
paul@308 | 498 | /* vim: tabstop=2 expandtab shiftwidth=2 |
paul@308 | 499 | */ |