Commit 653d2c4a authored by Alexandre Julliard's avatar Alexandre Julliard

server: Store the type of CPU that the client is running on.

parent b06a919c
......@@ -76,6 +76,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(server);
#define SOCKETNAME "socket" /* name of the socket file */
#define LOCKNAME "lock" /* name of the lock file */
#ifdef __i386__
static const enum cpu_type client_cpu = CPU_x86;
#elif defined(__x86_64__)
static const enum cpu_type client_cpu = CPU_x86_64;
#elif defined(__ALPHA__)
static const enum cpu_type client_cpu = CPU_ALPHA;
#elif defined(__powerpc__)
static const enum cpu_type client_cpu = CPU_POWERPC;
#elif defined(__sparc__)
static const enum cpu_type client_cpu = CPU_SPARC;
#else
#error Unsupported CPU
#endif
#ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
/* data structure used to pass an fd with sendmsg/recvmsg */
struct cmsg_fd
......@@ -1030,6 +1044,7 @@ size_t server_init_thread( void *entry_point )
req->reply_fd = reply_pipe[1];
req->wait_fd = ntdll_get_thread_data()->wait_fd[1];
req->debug_level = (TRACE_ON(server) != 0);
req->cpu = client_cpu;
ret = wine_server_call( req );
NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid);
NtCurrentTeb()->ClientId.UniqueThread = ULongToHandle(reply->tid);
......
......@@ -128,6 +128,13 @@ typedef union
} debug_event_t;
enum cpu_type
{
CPU_x86, CPU_x86_64, CPU_ALPHA, CPU_POWERPC, CPU_SPARC
};
typedef int cpu_type_t;
struct send_fd
{
thread_id_t tid;
......@@ -567,6 +574,7 @@ struct init_thread_request
client_ptr_t entry;
int reply_fd;
int wait_fd;
cpu_type_t cpu;
};
struct init_thread_reply
{
......@@ -5214,6 +5222,6 @@ union generic_reply
struct set_window_layered_info_reply set_window_layered_info_reply;
};
#define SERVER_PROTOCOL_VERSION 382
#define SERVER_PROTOCOL_VERSION 383
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -58,6 +58,7 @@ struct process
process_id_t id; /* id of the process */
process_id_t group_id; /* group id of the process */
struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */
enum cpu_type cpu; /* client CPU type */
int unix_pid; /* Unix pid for final SIGKILL */
int exit_code; /* process exit code */
int running_threads; /* number of threads running in this process */
......
......@@ -143,6 +143,13 @@ typedef union
} rip_info;
} debug_event_t;
/* supported CPU types */
enum cpu_type
{
CPU_x86, CPU_x86_64, CPU_ALPHA, CPU_POWERPC, CPU_SPARC
};
typedef int cpu_type_t;
/* structure used in sending an fd from client to server */
struct send_fd
{
......@@ -554,6 +561,7 @@ typedef union
client_ptr_t entry; /* entry point or PEB if initial thread (in thread address space) */
int reply_fd; /* fd for reply pipe */
int wait_fd; /* fd for blocking calls pipe */
cpu_type_t cpu; /* CPU that this thread is running on */
@REPLY
process_id_t pid; /* process id of the new thread's process */
thread_id_t tid; /* thread id of the new thread */
......
......@@ -600,6 +600,7 @@ C_ASSERT( sizeof(atom_t) == 4 );
C_ASSERT( sizeof(char) == 1 );
C_ASSERT( sizeof(char_info_t) == 4 );
C_ASSERT( sizeof(client_ptr_t) == 8 );
C_ASSERT( sizeof(cpu_type_t) == 4 );
C_ASSERT( sizeof(data_size_t) == 4 );
C_ASSERT( sizeof(file_pos_t) == 8 );
C_ASSERT( sizeof(int) == 4 );
......@@ -663,6 +664,7 @@ C_ASSERT( FIELD_OFFSET(struct init_thread_request, teb) == 24 );
C_ASSERT( FIELD_OFFSET(struct init_thread_request, entry) == 32 );
C_ASSERT( FIELD_OFFSET(struct init_thread_request, reply_fd) == 40 );
C_ASSERT( FIELD_OFFSET(struct init_thread_request, wait_fd) == 44 );
C_ASSERT( FIELD_OFFSET(struct init_thread_request, cpu) == 48 );
C_ASSERT( FIELD_OFFSET(struct init_thread_reply, pid) == 8 );
C_ASSERT( FIELD_OFFSET(struct init_thread_reply, tid) == 12 );
C_ASSERT( FIELD_OFFSET(struct init_thread_reply, server_start) == 16 );
......
......@@ -1045,10 +1045,16 @@ DECL_HANDLER(init_thread)
{
process->unix_pid = current->unix_pid;
process->peb = req->entry;
process->cpu = req->cpu;
reply->info_size = init_process( current );
}
else
{
if (req->cpu != process->cpu)
{
set_error( STATUS_INVALID_PARAMETER );
return;
}
if (process->unix_pid != current->unix_pid)
process->unix_pid = -1; /* can happen with linuxthreads */
if (current->suspend + process->suspend > 0) stop_thread( current );
......
......@@ -105,6 +105,21 @@ static void dump_ioctl_code( const ioctl_code_t *code )
}
}
static void dump_cpu_type( const cpu_type_t *code )
{
switch (*code)
{
#define CASE(c) case CPU_##c: fputs( #c, stderr ); break
CASE(x86);
CASE(x86_64);
CASE(ALPHA);
CASE(POWERPC);
CASE(SPARC);
default: fprintf( stderr, "%u", *code ); break;
#undef CASE
}
}
static void dump_apc_call( const apc_call_t *call )
{
fputc( '{', stderr );
......@@ -991,7 +1006,9 @@ static void dump_init_thread_request( const struct init_thread_request *req )
dump_uint64( &req->entry );
fprintf( stderr, "," );
fprintf( stderr, " reply_fd=%d,", req->reply_fd );
fprintf( stderr, " wait_fd=%d", req->wait_fd );
fprintf( stderr, " wait_fd=%d,", req->wait_fd );
fprintf( stderr, " cpu=" );
dump_cpu_type( &req->cpu );
}
static void dump_init_thread_reply( const struct init_thread_reply *req )
......
......@@ -50,6 +50,7 @@ my %formats =
"async_data_t" => [ 40, 8, "&dump_async_data" ],
"luid_t" => [ 8, 4, "&dump_luid" ],
"ioctl_code_t" => [ 4, 4, "&dump_ioctl_code" ],
"cpu_type_t" => [ 4, 4, "&dump_cpu_type" ],
);
my @requests = ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment