Skip to content

Commit d1aca7f

Browse files
Andrew Boienashif
authored andcommitted
x86_64: fix arch headers
arch/cpu.h and kernel_arch_func.h are expected to define different functions, per the architecture interface. Signed-off-by: Andrew Boie <[email protected]>
1 parent 7f715bd commit d1aca7f

File tree

2 files changed

+70
-65
lines changed

2 files changed

+70
-65
lines changed

arch/x86_64/include/kernel_arch_func.h

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -27,62 +27,14 @@ static inline struct _cpu *z_arch_curr_cpu(void)
2727
return (struct _cpu *)(long)ret;
2828
}
2929

30-
static inline unsigned int z_arch_irq_lock(void)
31-
{
32-
unsigned long long key;
33-
34-
__asm__ volatile("pushfq; cli; popq %0" : "=r"(key));
35-
return (int)key;
36-
}
37-
38-
static inline void z_arch_irq_unlock(unsigned int key)
39-
{
40-
if (key & 0x200) {
41-
__asm__ volatile("sti");
42-
}
43-
}
44-
45-
/**
46-
* Returns true if interrupts were unlocked prior to the
47-
* z_arch_irq_lock() call that produced the key argument.
48-
*/
49-
static inline bool z_arch_irq_unlocked(unsigned int key)
50-
{
51-
return (key & 0x200) != 0;
52-
}
53-
5430
static inline void z_arch_nop(void)
5531
{
5632
__asm__ volatile("nop");
5733
}
5834

59-
void z_arch_irq_disable(unsigned int irq);
60-
void z_arch_irq_enable(unsigned int irq);
61-
62-
/* Not a standard Zephyr function, but probably will be */
63-
static inline unsigned long long z_arch_k_cycle_get_64(void)
64-
{
65-
unsigned int hi, lo;
66-
67-
__asm__ volatile("rdtsc" : "=d"(hi), "=a"(lo));
68-
return (((unsigned long long)hi) << 32) | lo;
69-
}
70-
71-
static inline unsigned int z_arch_k_cycle_get_32(void)
35+
static inline bool z_arch_is_in_isr(void)
7236
{
73-
#ifdef CONFIG_HPET_TIMER
74-
extern u32_t z_timer_cycle_get_32(void);
75-
return z_timer_cycle_get_32();
76-
#else
77-
return (u32_t)z_arch_k_cycle_get_64();
78-
#endif
79-
}
80-
81-
#define z_arch_is_in_isr() (z_arch_curr_cpu()->nested != 0)
82-
83-
static inline void z_arch_switch(void *switch_to, void **switched_from)
84-
{
85-
xuk_switch(switch_to, switched_from);
37+
return z_arch_curr_cpu()->nested != 0U;
8638
}
8739

8840
static inline u32_t x86_apic_scaled_tsc(void)
@@ -95,21 +47,12 @@ static inline u32_t x86_apic_scaled_tsc(void)
9547
return (u32_t)(tsc >> CONFIG_XUK_APIC_TSC_SHIFT);
9648
}
9749

98-
void x86_apic_set_timeout(u32_t cyc_from_now);
99-
100-
#define Z_ARCH_IRQ_CONNECT(irq, pri, isr, arg, flags) \
101-
z_arch_irq_connect_dynamic(irq, pri, isr, arg, flags)
102-
103-
extern int x86_64_except_reason;
104-
50+
static inline void z_arch_switch(void *switch_to, void **switched_from)
51+
{
52+
xuk_switch(switch_to, switched_from);
53+
}
10554

106-
/* Vector 5 is the "bounds" exception which is otherwise vestigial
107-
* (BOUND is an illegal instruction in long mode)
108-
*/
109-
#define Z_ARCH_EXCEPT(reason) do { \
110-
x86_64_except_reason = reason; \
111-
__asm__ volatile("int $5"); \
112-
} while (false)
55+
void x86_apic_set_timeout(u32_t cyc_from_now);
11356

11457
void z_arch_sched_ipi(void);
11558

include/arch/x86_64/arch.h

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#ifndef _X86_64_ARCH_H
77
#define _X86_64_ARCH_H
88

9-
#include <kernel_arch_func.h>
109
#include <arch/common/sys_io.h>
1110
#include <arch/common/ffs.h>
1211

@@ -17,4 +16,67 @@
1716
#define DT_INST_0_INTEL_HPET_IRQ_0_PRIORITY 4
1817

1918
typedef struct z_arch_esf_t z_arch_esf_t;
19+
20+
static inline u32_t z_arch_k_cycle_get_32(void)
21+
{
22+
#ifdef CONFIG_HPET_TIMER
23+
extern u32_t z_timer_cycle_get_32(void);
24+
return z_timer_cycle_get_32();
25+
#else
26+
return (u32_t)z_arch_k_cycle_get_64();
27+
#endif
28+
}
29+
30+
/* Not a standard Zephyr function, but probably will be */
31+
static inline unsigned long long z_arch_k_cycle_get_64(void)
32+
{
33+
unsigned int hi, lo;
34+
35+
__asm__ volatile("rdtsc" : "=d"(hi), "=a"(lo));
36+
return (((unsigned long long)hi) << 32) | lo;
37+
}
38+
39+
static inline unsigned int z_arch_irq_lock(void)
40+
{
41+
unsigned long long key;
42+
43+
__asm__ volatile("pushfq; cli; popq %0" : "=r"(key));
44+
return (int)key;
45+
}
46+
47+
static inline void z_arch_irq_unlock(unsigned int key)
48+
{
49+
if (key & 0x200) {
50+
__asm__ volatile("sti");
51+
}
52+
}
53+
54+
/**
55+
* Returns true if interrupts were unlocked prior to the
56+
* z_arch_irq_lock() call that produced the key argument.
57+
*/
58+
static inline bool z_arch_irq_unlocked(unsigned int key)
59+
{
60+
return (key & 0x200) != 0;
61+
}
62+
63+
void z_arch_irq_enable(unsigned int irq);
64+
65+
void z_arch_irq_disable(unsigned int irq);
66+
67+
#define Z_ARCH_IRQ_CONNECT(irq, pri, isr, arg, flags) \
68+
z_arch_irq_connect_dynamic(irq, pri, isr, arg, flags)
69+
70+
extern int x86_64_except_reason;
71+
72+
73+
/* Vector 5 is the "bounds" exception which is otherwise vestigial
74+
* (BOUND is an illegal instruction in long mode)
75+
*/
76+
#define Z_ARCH_EXCEPT(reason) do { \
77+
x86_64_except_reason = reason; \
78+
__asm__ volatile("int $5"); \
79+
} while (false)
80+
81+
2082
#endif /* _X86_64_ARCH_H */

0 commit comments

Comments
 (0)