I'm wondering how the Linux kernel knows in which registers to look for function arguments when performing a system call. For example: I call the write system call from assembly. The arguments are stores in rdi, rsi and rdx. The kernel then calls the write function which looks something like write(fd, buf, len).
But how does the kernel know, that fd is stored in rdi, buf in rsi and len in rdx? How is the implementation? Is there some kind of a mapping in the kernel that initializes the arguments from these registers?
I guess im missing something. Maybe it doesn't even has something to do with these registers? I would appreciate some help :)