blob: 9fa5392e3122b7dbcf7d6debdf1bb7e27cc31e0e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#include "linux/sched.h"
8#include "linux/errno.h"
9#include "asm/system.h"
10#include "asm/pda.h"
11#include "sysdep/ptrace.h"
12#include "os.h"
13
14void arch_init_thread(void)
15{
16}
17
18void arch_check_bugs(void)
19{
20}
21
22int arch_handle_signal(int sig, union uml_pt_regs *regs)
23{
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070024 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025}
26
27#define MAXTOKEN 64
28
29/* Set during early boot */
30int host_has_cmov = 1;
31int host_has_xmm = 0;
32
33static char token(int fd, char *buf, int len, char stop)
34{
35 int n;
36 char *ptr, *end, c;
37
38 ptr = buf;
39 end = &buf[len];
40 do {
41 n = os_read_file(fd, ptr, sizeof(*ptr));
42 c = *ptr++;
43 if(n != sizeof(*ptr)){
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070044 if(n == 0)
45 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 printk("Reading /proc/cpuinfo failed, err = %d\n", -n);
47 if(n < 0)
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070048 return n;
49 else return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 }
51 } while((c != '\n') && (c != stop) && (ptr < end));
52
53 if(ptr == end){
54 printk("Failed to find '%c' in /proc/cpuinfo\n", stop);
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070055 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 }
57 *(ptr - 1) = '\0';
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070058 return c;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059}
60
61static int find_cpuinfo_line(int fd, char *key, char *scratch, int len)
62{
63 int n;
64 char c;
65
66 scratch[len - 1] = '\0';
67 while(1){
68 c = token(fd, scratch, len - 1, ':');
69 if(c <= 0)
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070070 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 else if(c != ':'){
72 printk("Failed to find ':' in /proc/cpuinfo\n");
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070073 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75
76 if(!strncmp(scratch, key, strlen(key)))
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070077 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79 do {
80 n = os_read_file(fd, &c, sizeof(c));
81 if(n != sizeof(c)){
82 printk("Failed to find newline in "
83 "/proc/cpuinfo, err = %d\n", -n);
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070084 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 }
86 } while(c != '\n');
87 }
Jeff Dikea5ed1ff2007-05-06 14:50:58 -070088 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}