Rev 1899 | Rev 1978 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1899 | Rev 1903 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | 33 | ||
34 | #include <ofwarch.h> |
34 | #include <ofwarch.h> |
35 | #include <ofw.h> |
35 | #include <ofw.h> |
36 | #include <printf.h> |
36 | #include <printf.h> |
37 | #include <string.h> |
37 | #include <string.h> |
- | 38 | #include <register.h> |
|
38 | #include "main.h" |
39 | #include "main.h" |
39 | 40 | ||
40 | void write(const char *str, const int len) |
41 | void write(const char *str, const int len) |
41 | { |
42 | { |
42 | int i; |
43 | int i; |
Line 51... | Line 52... | ||
51 | int ofw_translate_failed(ofw_arg_t flag) |
52 | int ofw_translate_failed(ofw_arg_t flag) |
52 | { |
53 | { |
53 | return flag != -1; |
54 | return flag != -1; |
54 | } |
55 | } |
55 | 56 | ||
56 | - | ||
57 | #define ASI_UPA_CONFIG 0x4a |
- | |
58 | #define UPA_CONFIG_MID_SHIFT 17 |
- | |
59 | #define UPA_CONFIG_MID_MASK 0x1f |
- | |
60 | - | ||
61 | int ofw_cpu(void) |
57 | int ofw_cpu(void) |
62 | { |
58 | { |
63 | char type_name[BUF_SIZE]; |
59 | char type_name[BUF_SIZE]; |
64 | 60 | ||
65 | phandle node; |
61 | phandle node; |
Line 72... | Line 68... | ||
72 | uint64_t current_mid; |
68 | uint64_t current_mid; |
73 | 69 | ||
74 | __asm__ volatile ("ldxa [%1] %2, %0\n" : "=r" (current_mid) : "r" (0), "i" (ASI_UPA_CONFIG)); |
70 | __asm__ volatile ("ldxa [%1] %2, %0\n" : "=r" (current_mid) : "r" (0), "i" (ASI_UPA_CONFIG)); |
75 | current_mid >>= UPA_CONFIG_MID_SHIFT; |
71 | current_mid >>= UPA_CONFIG_MID_SHIFT; |
76 | current_mid &= UPA_CONFIG_MID_MASK; |
72 | current_mid &= UPA_CONFIG_MID_MASK; |
- | 73 | ||
- | 74 | int cpus; |
|
77 | 75 | ||
78 | for (; node != 0 && node != -1; node = ofw_get_peer_node(node)) { |
76 | for (cpus = 0; node != 0 && node != -1; node = ofw_get_peer_node(node), cpus++) { |
79 | if (ofw_get_property(node, "device_type", type_name, sizeof(type_name)) > 0) { |
77 | if (ofw_get_property(node, "device_type", type_name, sizeof(type_name)) > 0) { |
80 | if (strcmp(type_name, "cpu") == 0) { |
78 | if (strcmp(type_name, "cpu") == 0) { |
81 | uint32_t mid; |
79 | uint32_t mid; |
82 | 80 | ||
83 | if (ofw_get_property(node, "upa-portid", &mid, sizeof(mid)) <= 0) |
81 | if (ofw_get_property(node, "upa-portid", &mid, sizeof(mid)) <= 0) |
Line 91... | Line 89... | ||
91 | } |
89 | } |
92 | } |
90 | } |
93 | } |
91 | } |
94 | } |
92 | } |
95 | 93 | ||
96 | return 1; |
94 | return cpus; |
97 | } |
95 | } |