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(Cpu_number 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]:
42 DEFINE_PER_CPU Per_cpu<Cpu> Cpu::cpus(Per_cpu_data::Cpu_num);
44 unsigned long Cpu::_ns_per_cycle;
46 PUBLIC static inline unsigned Cpu::phys_bits() { return 32; }
50 Cpu::init(bool is_boot_cpu)
58 _phys_id = Cpu_phys_id(0); //Proc::cpu_id();
59 _ns_per_cycle = 0; //1000000000 / Boot_info::get_time_base();
60 //printf("Timebase: %lu\n", Boot_info::get_time_base());
76 Cpu::read_vsid(unsigned sr = 0)
81 return (vsid & 0xffffff);
84 /* set segment register 0-15 */
85 PUBLIC static inline //NEEDS["paging.h"]
87 Cpu::set_vsid(Mword vsid)
89 vsid |= Segment::Default_attribs;
94 Cpu::stack_align(Mword stack)
95 { return stack & ~0xf; }
99 Cpu::have_superpages()
102 //------------------------------------------------------------------------------
106 * Read time base registers
112 Unsigned32 tb_upper, tb_lower;
115 return (tb << 32) | tb_lower;
120 Cpu::busy_wait_ns(Unsigned64 ns)
122 Unsigned64 stop = rdtsc() + ns_to_tsc(ns);
124 while(rdtsc() < stop)
130 Cpu::ns_to_tsc(Unsigned64 ns)
132 return ns / _ns_per_cycle;
137 Cpu::tsc_to_ns(Unsigned64 tsc)
139 return tsc * _ns_per_cycle;
144 Cpu::get_scaler_tsc_to_ns()
149 Cpu::get_scaler_tsc_to_us()
154 Cpu::get_scaler_ns_to_tsc()
162 //------------------------------------------------------------------------------
167 Cpu::debugctl_enable()
172 Cpu::debugctl_disable()