| ... | ... | @@ -389,6 +389,61 @@ fn clone() callconv(.Naked) void { |
| 389 | 389 | \\ syscall |
| 390 | 390 | ); |
| 391 | 391 | }, |
| 392 | |
| 393 | .powerpc64, .powerpc64le => { |
| 394 | asm volatile ( |
| 395 | \\ # store non-volatile regs r30, r31 on stack in order to put our |
| 396 | \\ # start func and its arg there |
| 397 | \\ stwu 30, -16(1) |
| 398 | \\ stw 31, 4(1) |
| 399 | \\ # save r3 (func) into r30, and r6(arg) into r31 |
| 400 | \\ mr 30, 3 |
| 401 | \\ mr 31, 6 |
| 402 | \\ # create initial stack frame for new thread |
| 403 | \\ clrrwi 4, 4, 4 |
| 404 | \\ li 0, 0 |
| 405 | \\ stwu 0, -16(4) |
| 406 | \\ #move c into first arg |
| 407 | \\ mr 3, 5 |
| 408 | \\ mr 5, 7 |
| 409 | \\ mr 6, 8 |
| 410 | \\ mr 7, 9 |
| 411 | \\ # move syscall number into r0 |
| 412 | \\ li 0, 120 |
| 413 | \\ sc |
| 414 | |
| 415 | \\ # check for syscall error |
| 416 | \\ bns+ 1f # jump to label 1 if no summary overflow. |
| 417 | \\ #else |
| 418 | \\ neg 3, 3 #negate the result (errno) |
| 419 | \\1: |
| 420 | \\ # compare sc result with 0 |
| 421 | \\ cmpwi cr7, 3, 0 |
| 422 | |
| 423 | \\ # if not 0, jump to end |
| 424 | \\ bne cr7, 2f |
| 425 | |
| 426 | \\ #else: we're the child |
| 427 | \\ #call funcptr: move arg (d) into r3 |
| 428 | \\ mr 3, 31 |
| 429 | \\ #move r30 (funcptr) into CTR reg |
| 430 | \\ mtctr 30 |
| 431 | \\ # call CTR reg |
| 432 | \\ bctrl |
| 433 | \\ # mov SYS_exit into r0 (the exit param is already in r3) |
| 434 | \\ li 0, 1 |
| 435 | \\ sc |
| 436 | |
| 437 | \\2: |
| 438 | \\ # restore stack |
| 439 | \\ lwz 30, 0(1) |
| 440 | \\ lwz 31, 4(1) |
| 441 | \\ addi 1, 1, 16 |
| 442 | |
| 443 | \\ blr |
| 444 | ); |
| 445 | }, |
| 446 | |
| 392 | 447 | else => @compileError("Implement clone() for this arch."), |
| 393 | 448 | } |
| 394 | 449 | } |