Commit 339ed576 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Get rid of the CPU type and functions.

parent 308bd357
......@@ -70,25 +70,8 @@ static ULONG execute_flags = MEM_EXECUTE_OPTION_DISABLE | (sizeof(void *) > size
MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION |
MEM_EXECUTE_OPTION_PERMANENT : 0);
static const char * const cpu_names[] = { "x86", "x86_64", "ARM", "ARM64" };
static UINT process_error_mode;
static client_cpu_t get_machine_cpu( pe_image_info_t *pe_info )
{
switch (pe_info->machine)
{
case IMAGE_FILE_MACHINE_I386:
if ((is_win64 || is_wow64) && (pe_info->image_flags & IMAGE_FLAGS_ComPlusNativeReady))
return CPU_x86_64;
return CPU_x86;
case IMAGE_FILE_MACHINE_AMD64: return CPU_x86_64;
case IMAGE_FILE_MACHINE_ARMNT: return CPU_ARM;
case IMAGE_FILE_MACHINE_ARM64: return CPU_ARM64;
default: return 0;
}
}
static char **build_argv( const UNICODE_STRING *cmdline, int reserved )
{
char **argv, *arg, *src, *dst;
......@@ -714,7 +697,6 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_
req->flags = process_flags;
req->socket_fd = socketfd[1];
req->access = process_access;
req->cpu = get_machine_cpu( &pe_info );
req->info_size = startup_info_size;
req->handles_size = handles_size;
wine_server_add_data( req, objattr, attr_len );
......@@ -740,8 +722,8 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_
ERR( "64-bit application %s not supported in 32-bit prefix\n", debugstr_us(&path) );
break;
case STATUS_INVALID_IMAGE_FORMAT:
ERR( "%s not supported on this installation (%s binary)\n",
debugstr_us(&path), cpu_names[get_machine_cpu(&pe_info)] );
ERR( "%s not supported on this installation (machine %04x)\n",
debugstr_us(&path), pe_info.machine );
break;
}
goto done;
......
......@@ -1561,7 +1561,6 @@ size_t server_init_process(void)
req->reply_fd = reply_pipe;
req->wait_fd = ntdll_get_thread_data()->wait_fd[1];
req->debug_level = (TRACE_ON(server) != 0);
req->cpu = client_cpu;
wine_server_set_reply( req, supported_machines, sizeof(supported_machines) );
ret = wine_server_call( req );
NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid);
......
......@@ -28,16 +28,12 @@
#include "wine/list.h"
#ifdef __i386__
static const enum cpu_type client_cpu = CPU_x86;
static const WORD current_machine = IMAGE_FILE_MACHINE_I386;
#elif defined(__x86_64__)
static const enum cpu_type client_cpu = CPU_x86_64;
static const WORD current_machine = IMAGE_FILE_MACHINE_AMD64;
#elif defined(__arm__)
static const enum cpu_type client_cpu = CPU_ARM;
static const WORD current_machine = IMAGE_FILE_MACHINE_ARMNT;
#elif defined(__aarch64__)
static const enum cpu_type client_cpu = CPU_ARM64;
static const WORD current_machine = IMAGE_FILE_MACHINE_ARM64;
#endif
......
......@@ -110,13 +110,6 @@ typedef union
} debug_event_t;
enum cpu_type
{
CPU_x86, CPU_x86_64, CPU_ARM, CPU_ARM64
};
typedef int client_cpu_t;
typedef struct
{
unsigned int machine;
......@@ -832,7 +825,8 @@ struct new_process_request
unsigned int flags;
int socket_fd;
unsigned int access;
client_cpu_t cpu;
unsigned short machine;
char __pad_38[2];
data_size_t info_size;
data_size_t handles_size;
/* VARARG(objattr,object_attributes); */
......@@ -926,8 +920,6 @@ struct init_first_thread_request
client_ptr_t ldt_copy;
int reply_fd;
int wait_fd;
client_cpu_t cpu;
char __pad_60[4];
};
struct init_first_thread_reply
{
......@@ -6219,7 +6211,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 695
#define SERVER_PROTOCOL_VERSION 696
/* ### protocol_version end ### */
......
......@@ -134,7 +134,7 @@ static const struct object_ops debug_obj_ops =
/* get a pointer to TEB->ArbitraryUserPointer in the client address space */
static client_ptr_t get_teb_user_ptr( struct thread *thread )
{
unsigned int ptr_size = (CPU_FLAG( thread->process->cpu ) & CPU_64BIT_MASK) ? 8 : 4;
unsigned int ptr_size = is_machine_64bit( thread->process->machine ) ? 8 : 4;
return thread->teb + 5 * ptr_size;
}
......
......@@ -240,7 +240,7 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
#ifdef __x86_64__
if (thread->process->cpu == CPU_x86_64)
if (thread->process->machine == IMAGE_FILE_MACHINE_AMD64)
{
/* Mac OS doesn't allow setting the global breakpoint flags */
dr7 = (context->debug.x86_64_regs.dr7 & ~0xaa) | ((context->debug.x86_64_regs.dr7 & 0xaa) >> 1);
......
......@@ -238,7 +238,6 @@ extern void generate_startup_debug_events( struct process *process );
/* registry functions */
extern unsigned int get_prefix_cpu_mask(void);
extern unsigned int supported_machines_count;
extern unsigned short supported_machines[8];
extern void init_registry(void);
......
......@@ -1045,11 +1045,6 @@ DECL_HANDLER(new_process)
close( socket_fd );
return;
}
if (!is_cpu_supported( req->cpu ))
{
close( socket_fd );
return;
}
if (req->parent_process)
{
......
......@@ -52,7 +52,6 @@ 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 */
unsigned short machine; /* client machine type */
int unix_pid; /* Unix pid for final SIGKILL */
int exit_code; /* process exit code */
......@@ -90,9 +89,6 @@ struct process
struct list kernel_object; /* list of kernel object pointers */
};
#define CPU_FLAG(cpu) (1 << (cpu))
#define CPU_64BIT_MASK (CPU_FLAG(CPU_x86_64) | CPU_FLAG(CPU_ARM64))
/* process functions */
extern unsigned int alloc_ptid( void *ptr );
......
......@@ -125,13 +125,6 @@ typedef union
} unload_dll;
} debug_event_t;
/* supported CPU types */
enum cpu_type
{
CPU_x86, CPU_x86_64, CPU_ARM, CPU_ARM64
};
typedef int client_cpu_t;
/* context data */
typedef struct
{
......@@ -846,7 +839,7 @@ typedef struct
unsigned int flags; /* process creation flags */
int socket_fd; /* file descriptor for process socket */
unsigned int access; /* access rights for process object */
client_cpu_t cpu; /* CPU that the new process will use */
unsigned short machine; /* architecture that the new process will use */
data_size_t info_size; /* size of startup info */
data_size_t handles_size; /* length of explicit handles list */
VARARG(objattr,object_attributes); /* object attributes */
......@@ -909,7 +902,6 @@ typedef struct
client_ptr_t ldt_copy; /* address of LDT copy (in process address space) */
int reply_fd; /* fd for reply pipe */
int wait_fd; /* fd for blocking calls pipe */
client_cpu_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 */
......
......@@ -1769,34 +1769,6 @@ static WCHAR *format_user_registry_path( const SID *sid, struct unicode_str *pat
return ascii_to_unicode_str( buffer, path );
}
/* get the cpu architectures that can be supported in the current prefix */
unsigned int get_prefix_cpu_mask(void)
{
/* Allowed server/client/prefix combinations:
*
* prefix
* 32 64
* server +------+------+ client
* | ok | fail | 32
* 32 +------+------+---
* | fail | fail | 64
* ---+------+------+---
* | ok | ok | 32
* 64 +------+------+---
* | fail | ok | 64
* ---+------+------+---
*/
switch (prefix_type)
{
case PREFIX_64BIT:
/* 64-bit prefix requires 64-bit server */
return sizeof(void *) > sizeof(int) ? ~0 : 0;
case PREFIX_32BIT:
default:
return ~CPU_64BIT_MASK; /* only 32-bit cpus supported on 32-bit prefix */
}
}
static void init_supported_machines(void)
{
unsigned int count = 0;
......@@ -2072,7 +2044,7 @@ void flush_registry(void)
/* determine if the thread is wow64 (32-bit client running on 64-bit prefix) */
static int is_wow64_thread( struct thread *thread )
{
return (prefix_type == PREFIX_64BIT && !(CPU_FLAG(thread->process->cpu) & CPU_64BIT_MASK));
return (is_machine_64bit( supported_machines[0] ) && !is_machine_64bit( thread->process->machine ));
}
......
......@@ -681,7 +681,6 @@ C_ASSERT( sizeof(apc_result_t) == 40 );
C_ASSERT( sizeof(async_data_t) == 40 );
C_ASSERT( sizeof(atom_t) == 4 );
C_ASSERT( sizeof(char) == 1 );
C_ASSERT( sizeof(client_cpu_t) == 4 );
C_ASSERT( sizeof(client_ptr_t) == 8 );
C_ASSERT( sizeof(data_size_t) == 4 );
C_ASSERT( sizeof(file_pos_t) == 8 );
......@@ -710,7 +709,7 @@ C_ASSERT( FIELD_OFFSET(struct new_process_request, parent_process) == 20 );
C_ASSERT( FIELD_OFFSET(struct new_process_request, flags) == 24 );
C_ASSERT( FIELD_OFFSET(struct new_process_request, socket_fd) == 28 );
C_ASSERT( FIELD_OFFSET(struct new_process_request, access) == 32 );
C_ASSERT( FIELD_OFFSET(struct new_process_request, cpu) == 36 );
C_ASSERT( FIELD_OFFSET(struct new_process_request, machine) == 36 );
C_ASSERT( FIELD_OFFSET(struct new_process_request, info_size) == 40 );
C_ASSERT( FIELD_OFFSET(struct new_process_request, handles_size) == 44 );
C_ASSERT( sizeof(struct new_process_request) == 48 );
......@@ -746,8 +745,7 @@ C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, peb) == 32 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, ldt_copy) == 40 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, reply_fd) == 48 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, wait_fd) == 52 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_request, cpu) == 56 );
C_ASSERT( sizeof(struct init_first_thread_request) == 64 );
C_ASSERT( sizeof(struct init_first_thread_request) == 56 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_reply, pid) == 8 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_reply, tid) == 12 );
C_ASSERT( FIELD_OFFSET(struct init_first_thread_reply, server_start) == 16 );
......
......@@ -53,18 +53,6 @@
#include "security.h"
#ifdef __i386__
static const unsigned int supported_cpus = CPU_FLAG(CPU_x86);
#elif defined(__x86_64__)
static const unsigned int supported_cpus = CPU_FLAG(CPU_x86_64) | CPU_FLAG(CPU_x86);
#elif defined(__arm__)
static const unsigned int supported_cpus = CPU_FLAG(CPU_ARM);
#elif defined(__aarch64__)
static const unsigned int supported_cpus = CPU_FLAG(CPU_ARM64) | CPU_FLAG(CPU_ARM);
#else
#error Unsupported CPU
#endif
/* thread queues */
struct thread_wait
......@@ -1326,21 +1314,6 @@ struct token *thread_get_impersonation_token( struct thread *thread )
return thread->process->token;
}
/* check if a cpu type can be supported on this server */
int is_cpu_supported( enum cpu_type cpu )
{
unsigned int prefix_cpu_mask = get_prefix_cpu_mask();
if (supported_cpus & prefix_cpu_mask & CPU_FLAG(cpu)) return 1;
if (!(supported_cpus & prefix_cpu_mask))
set_error( STATUS_NOT_SUPPORTED );
else if (supported_cpus & CPU_FLAG(cpu))
set_error( STATUS_INVALID_IMAGE_WIN_64 ); /* server supports it but not the prefix */
else
set_error( STATUS_INVALID_IMAGE_FORMAT );
return 0;
}
/* create a new thread */
DECL_HANDLER(new_thread)
{
......@@ -1444,7 +1417,6 @@ DECL_HANDLER(init_first_thread)
current->teb = req->teb;
process->peb = req->peb;
process->ldt_copy = req->ldt_copy;
process->cpu = req->cpu;
if (!process->parent_id)
process->affinity = current->affinity = get_thread_affinity( current );
......
......@@ -119,7 +119,6 @@ extern int thread_add_inflight_fd( struct thread *thread, int client, int server
extern int thread_get_inflight_fd( struct thread *thread, int client );
extern struct token *thread_get_impersonation_token( struct thread *thread );
extern int set_thread_affinity( struct thread *thread, affinity_t affinity );
extern int is_cpu_supported( enum cpu_type cpu );
extern int suspend_thread( struct thread *thread );
extern int resume_thread( struct thread *thread );
......
......@@ -147,20 +147,6 @@ static void dump_ioctl_code( const char *prefix, const ioctl_code_t *code )
}
}
static void dump_client_cpu( const char *prefix, const client_cpu_t *code )
{
switch (*code)
{
#define CASE(c) case CPU_##c: fprintf( stderr, "%s%s", prefix, #c ); break
CASE(x86);
CASE(x86_64);
CASE(ARM);
CASE(ARM64);
default: fprintf( stderr, "%s%u", prefix, *code ); break;
#undef CASE
}
}
static void dump_apc_call( const char *prefix, const apc_call_t *call )
{
fprintf( stderr, "%s{", prefix );
......@@ -1370,7 +1356,7 @@ static void dump_new_process_request( const struct new_process_request *req )
fprintf( stderr, ", flags=%08x", req->flags );
fprintf( stderr, ", socket_fd=%d", req->socket_fd );
fprintf( stderr, ", access=%08x", req->access );
dump_client_cpu( ", cpu=", &req->cpu );
fprintf( stderr, ", machine=%04x", req->machine );
fprintf( stderr, ", info_size=%u", req->info_size );
fprintf( stderr, ", handles_size=%u", req->handles_size );
dump_varargs_object_attributes( ", objattr=", cur_size );
......@@ -1443,7 +1429,6 @@ static void dump_init_first_thread_request( const struct init_first_thread_reque
dump_uint64( ", ldt_copy=", &req->ldt_copy );
fprintf( stderr, ", reply_fd=%d", req->reply_fd );
fprintf( stderr, ", wait_fd=%d", req->wait_fd );
dump_client_cpu( ", cpu=", &req->cpu );
}
static void dump_init_first_thread_reply( const struct init_first_thread_reply *req )
......
......@@ -52,7 +52,6 @@ my %formats =
"luid_t" => [ 8, 4, "&dump_luid" ],
"generic_map_t" => [ 16, 4, "&dump_generic_map" ],
"ioctl_code_t" => [ 4, 4, "&dump_ioctl_code" ],
"client_cpu_t" => [ 4, 4, "&dump_client_cpu" ],
"hw_input_t" => [ 32, 8, "&dump_hw_input" ],
);
......
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