Ignore:
Timestamp:
2024-09-20T12:16:28Z (8 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
d3109ff
Parents:
2cf8f994
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-09-20 11:42:13)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-09-20 12:16:28)
Message:

Simplify the SYS_THREAD_CREATE syscall interface

Removed the beefy uarg structure. Instead, the syscall gets two
parameters: %pc (program counter) and %sp (stack pointer). It starts
a thread with those values in corresponding registers, with no other
fuss whatsoever.

libc initializes threads by storing any other needed arguments on
the stack and retrieving them in thread_entry. Importantly, this
includes the address of the
thread_main function which is now
called indirectly to fix dynamic linking issues on some archs.

There's a bit of weirdness on SPARC and IA-64, because of their
stacked register handling. The current solution is that we require
some space *above* the stack pointer to be available for those
architectures. I think for SPARC, it can be made more normal.

For the remaining ones, we can (probably) just set the initial
%sp to the top edge of the stack. There's some lingering offsets
on some archs just because I didn't want to accidentally break
anything. The initial thread bringup should be functionally
unchanged from the previous state, and no binaries are currently
multithreaded except thread1 test, so there should be minimal
risk of breakage. Naturally, I tested all available emulator
builds, save for msim.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia64/src/thread_entry.S

    r2cf8f994 r3fcea34  
    3737        alloc loc0 = ar.pfs, 0, 1, 1, 0
    3838
    39 #ifndef CONFIG_RTLD
    40         # XXX This does not work in a shared library
    41         movl gp = __gp
    42 #endif
     39        add r8 = -8, sp ;;
     40        # Entry function argument
     41        ld8 out0 = [r8], -8 ;;
    4342
    44         #
    45         # r8 contains address of uarg structure.
    46         #
     43        # Entry function descriptor
     44        ld8 r8 = [r8] ;;
     45        # Entry function address
     46        ld8 r9 = [r8], 8 ;;
     47        # Entry function global pointer
     48        ld8 gp = [r8] ;;
    4749
    48         mov out0 = r8 ;;
    49         # XXX br.call.sptk.many b0 = FUNCTION_REF(__thread_main)
    50         br.call.sptk.many b0 = __thread_main
     50        mov b1 = r9 ;;
     51
     52        br.call.sptk.many b0 = b1 ;;
    5153
    5254        #
Note: See TracChangeset for help on using the changeset viewer.