inline float log10(const float& a0) { typedef float A0; if (a0 == Inf<A0>()) return a0; if (iseqz(a0)) return Minf<A0>(); if (nt2::is_nan(a0)||isltz(a0)) return Nan<A0>(); A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = amul(y, -Half<A0>(), x2); // multiply log of fraction by log10(e) and base 2 exponent by log10(2) A0 z = mul(x+y, Const<float, 0x3a37b152>());//7.00731903251827651129E-4f // log10(e)lo z = amul(z, y, Const<float, 0x3ede0000>()); //4.3359375E-1f // log10(e)hi z = amul(z, x, Const<float, 0x3ede0000>()); z = amul(z, fe, Const<float, 0x39826a14>());//3.0078125E-1f // log10(2)hi return amul(z, fe, Const<float, 0x3e9a0000 >());//2.48745663981195213739E-4f // log10(2)lo }
static inline A0 log2(const A0& a0) { typedef typename meta::strip<A0>::type stA0; if (a0 == Inf<stA0>()) return a0; if (is_eqz(a0)) return Minf<stA0>(); if (nt2::is_nan(a0)||is_ltz(a0)) return Nan<stA0>(); A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = madd(Mhalf<stA0>(),x2, y); // multiply log of fraction by log2(e) A0 z = madd( x , single_constant<stA0, 0x3ee2a8ed>() , mul(y,single_constant<stA0, 0x3ee2a8ed>())// 0.44269504088896340735992 ); return ((z+y)+x)+fe; }
inline float log2(const float& a0) { typedef float A0; if (a0 == Inf<A0>()) return a0; if (iseqz(a0)) return Minf<A0>(); if (nt2::is_nan(a0)||is_ltz(a0)) return Nan<A0>(); A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = fma(Mhalf<A0>(),x2, y); // multiply log of fraction by log2(e) A0 z = fma( x , Const<float, 0x3ee2a8ed>() , mul(y,Const<float, 0x3ee2a8ed>())// 0.44269504088896340735992 ); return ((z+y)+x)+fe; }
static inline A0 log10(const A0& a0) { typedef typename meta::strip<A0>::type stA0; if (a0 == Inf<stA0>()) return a0; if (is_eqz(a0)) return Minf<stA0>(); if (nt2::is_nan(a0)||is_ltz(a0)) return Nan<stA0>(); A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = amul(y, Mhalf<stA0>(), x2); // multiply log of fraction by log10(e) and base 2 exponent by log10(2) A0 z = mul(x+y, single_constant<stA0, 0x3a37b152>());//7.00731903251827651129E-4f // log10(e)lo z = amul(z, y, single_constant<stA0, 0x3ede0000>()); //4.3359375E-1f // log10(e)hi z = amul(z, x, single_constant<stA0, 0x3ede0000>()); z = amul(z, fe, single_constant<stA0, 0x39826a14>());//3.0078125E-1f // log10(2)hi return amul(z, fe, single_constant<stA0, 0x3e9a0000 >());//2.48745663981195213739E-4f // log10(2)lo }
static inline A0 log(const A0& a0) { A0 x, fe, x2, y; kernel_log(a0, fe, x, x2, y); y = madd(fe, single_constant<A0, 0xb95e8083>(), y); y = madd(Mhalf<A0>(), x2, y); A0 z = x + y; // std::cout << "fe " << fe << std::endl; // std::cout << "z " << z << std::endl; // std::cout << "a0 " << a0 << std::endl; // std::cout << "rec(a0) " << rec(a0) << std::endl; A0 y1 = a0-rec(abs(a0));// trick to reduce selection testing A0 y2 = madd(single_constant<A0, 0x3f318000>(), fe, z); // std::cout << "y1 " << y1 << std::endl; // std::cout << "y2 " << y2 << std::endl; return seladd(is_inf(y1),b_or(y2, b_or(is_ltz(a0), is_nan(a0))),y1); }
/* Called by main, sets up the special GDT pointer, * sets up the first 3 entries in our GDT, and then * calls gdt_flush() in our assembler file in order * to tell the processor where the new GDT is and update * the segment registers */ void gdt_install() { kernel_log("os", "Installing GDT\n"); _gp.limit = (sizeof(struct gdt_entry) * 3) - 1; _gp.base = (uint32_t) &gdt; // NULL descriptor gdt_set_gate(0, 0, 0, 0, 0); // Code Segment gdt_set_gate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF); // Data Segment gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); // Flush out the old GDT and install the new changes! _gdt_flush(); }
static inline A0 log(const A0& a0) { // ln(2)hi = 6.93147180369123816490e-01 or 0x3fe62e42fee00000 // ln(2)lo = 1.90821492927058770002e-10 or 0x3dea39ef35793c76 #ifndef BOOST_SIMD_NO_INFINITIES if (a0 == Inf<A0>()) return a0; #endif if (is_eqz(a0)) return nt2::Minf<A0>(); #ifdef BOOST_SIMD_NO_NANS if (nt2::is_ltz(a0)) return nt2::Nan<A0>(); #else if (nt2::is_nan(a0)||nt2::is_ltz(a0)) return nt2::Nan<A0>(); #endif A0 dk, hfsq, s, R, f; kernel_log(a0, dk, hfsq, s, R, f); return nt2::mul(dk, double_constant<A0, 0x3fe62e42fee00000ll>())- ((hfsq-(s*(hfsq+R)+nt2::mul(dk,double_constant<A0, 0x3dea39ef35793c76ll>())))-f); }
void irq_install() { irq_remap(); kernel_log("os", "Installing IRQs\n"); idt_set_gate(32, (unsigned)_irq0, 0x08, 0x8E); idt_set_gate(33, (unsigned)_irq1, 0x08, 0x8E); idt_set_gate(34, (unsigned)_irq2, 0x08, 0x8E); idt_set_gate(35, (unsigned)_irq3, 0x08, 0x8E); idt_set_gate(36, (unsigned)_irq4, 0x08, 0x8E); idt_set_gate(37, (unsigned)_irq5, 0x08, 0x8E); idt_set_gate(38, (unsigned)_irq6, 0x08, 0x8E); idt_set_gate(39, (unsigned)_irq7, 0x08, 0x8E); idt_set_gate(40, (unsigned)_irq8, 0x08, 0x8E); idt_set_gate(41, (unsigned)_irq9, 0x08, 0x8E); idt_set_gate(42, (unsigned)_irq10, 0x08, 0x8E); idt_set_gate(43, (unsigned)_irq11, 0x08, 0x8E); idt_set_gate(44, (unsigned)_irq12, 0x08, 0x8E); idt_set_gate(45, (unsigned)_irq13, 0x08, 0x8E); idt_set_gate(46, (unsigned)_irq14, 0x08, 0x8E); idt_set_gate(47, (unsigned)_irq15, 0x08, 0x8E); }