3 #include "per_cpu_data.h"
9 void init(bool is_boot_cpu = false);
10 static void early_init();
12 static Per_cpu<Cpu> cpus;
13 static Cpu *boot_cpu() { return _boot_cpu; }
15 Cpu(unsigned cpu) { set_id(cpu); }
18 static Cpu *_boot_cpu;
20 static unsigned long _ns_per_cycle;
31 Default_attribs = Kp //Ks | Kp,
34 //------------------------------------------------------------------------------
35 IMPLEMENTATION [sparc]:
38 #include "boot_info.h"
43 DEFINE_PER_CPU Per_cpu<Cpu> Cpu::cpus(true);
45 unsigned long Cpu::_ns_per_cycle;
49 Cpu::init(bool is_boot_cpu)
56 _phys_id = 0; //Proc::cpu_id();
57 _ns_per_cycle = 0; //1000000000 / Boot_info::get_time_base();
58 //printf("Timebase: %lu\n", Boot_info::get_time_base());
74 Cpu::read_vsid(unsigned sr = 0)
79 return (vsid & 0xffffff);
82 /* set segment register 0-15 */
83 PUBLIC static inline //NEEDS["paging.h"]
85 Cpu::set_vsid(Mword vsid)
87 vsid |= Segment::Default_attribs;
92 Cpu::stack_align(Mword stack)
93 { return stack & ~0xf; }
97 Cpu::have_superpages()
100 //------------------------------------------------------------------------------
104 * Read time base registers
110 Unsigned32 tb_upper, tb_lower;
113 return (tb << 32) | tb_lower;
118 Cpu::busy_wait_ns(Unsigned64 ns)
120 Unsigned64 stop = rdtsc() + ns_to_tsc(ns);
122 while(rdtsc() < stop)
128 Cpu::ns_to_tsc(Unsigned64 ns)
130 return ns / _ns_per_cycle;
135 Cpu::tsc_to_ns(Unsigned64 tsc)
137 return tsc * _ns_per_cycle;
142 Cpu::get_scaler_tsc_to_ns()
147 Cpu::get_scaler_tsc_to_us()
152 Cpu::get_scaler_ns_to_tsc()
160 //------------------------------------------------------------------------------
165 Cpu::debugctl_enable()
170 Cpu::debugctl_disable()