imcplugin demo: Extend to support stat() call
[nativeclient.git] / sandbox / linux / nacl_registers.h
blob559345390fe1b84f011adaaf75c90edd6047f505
1 // Copyright 2009 Google Inc. All Rights Reserved.
2 // Author: neha@google.com (Neha Narula)
3 //
4 // Control access to registers. Provides an abstraction for i386
5 // vs. x86_64.
7 #ifndef NATIVE_CLIENT_SANDBOX_LINUX_NACL_REGISTERS_H_
8 #define NATIVE_CLIENT_SANDBOX_LINUX_NACL_REGISTERS_H_
10 #include <cstddef>
11 #include <sys/user.h>
12 #include <stdint.h>
14 class Registers {
15 public:
16 // Gets the CS register.
17 static uintptr_t GetCS(const user_regs_struct& regs);
18 // Gets the syscall userspace is trying to execute.
19 static uintptr_t GetSyscall(const user_regs_struct& regs);
20 // Gets the first syscall argument register.
21 static uintptr_t GetReg1(const user_regs_struct& regs);
22 // Gets the second syscall argument register.
23 static uintptr_t GetReg2(const user_regs_struct& regs);
24 // Gets the third syscall argument register.
25 static uintptr_t GetReg3(const user_regs_struct& regs);
26 // Gets the fourth syscall argument register.
27 static uintptr_t GetReg4(const user_regs_struct& regs);
28 // Gets the fifth syscall argument register.
29 static uintptr_t GetReg5(const user_regs_struct& regs);
30 // Gets the sixth syscall argument register.
31 static uintptr_t GetReg6(const user_regs_struct& regs);
32 // Gets the value pointed to as a string
33 static bool GetStringVal(uintptr_t reg_val, size_t max_length,
34 pid_t pid, char* result);
36 // Sets the first syscall argument register.
37 static void SetReg1(struct user_regs_struct* regs, uintptr_t val);
38 // Sets the second syscall argument register.
39 static void SetReg2(struct user_regs_struct* regs, uintptr_t val);
40 // Sets the third syscall argument register.
41 static void SetReg3(struct user_regs_struct* regs, uintptr_t val);
42 // Sets the fourth syscall argument register.
43 static void SetReg4(struct user_regs_struct* regs, uintptr_t val);
44 // Sets the fifth syscall argument register.
45 static void SetReg5(struct user_regs_struct* regs, uintptr_t val);
46 // Sets the sixth syscall argument register.
47 static void SetReg6(struct user_regs_struct* regs, uintptr_t val);
50 #endif // NATIVE_CLIENT_SANDBOX_LINUX_NACL_REGISTERS_H_