arch/x86_64: fix build break if disable CONFIG_SPINLOCK

Create version.h
chip/intel64_irq.c:78:34: error: conflicting type qualifiers for ‘g_irq_spin’
   78 | static spinlock_t                g_irq_spin;
      |                                  ^~~~~~~~~~
In file included from chip/intel64_irq.c:40:
include/nuttx/spinlock.h:168:28: note: previous declaration of ‘g_irq_spin’ with type ‘spinlock_t’ {aka ‘volatile unsigned char’}
  168 | extern volatile spinlock_t g_irq_spin;
      |                            ^~~~~~~~~~
chip/intel64_cpu.c: In function ‘x86_64_cpu_ready_set’:
chip/intel64_cpu.c:314:3: warning: implicit declaration of function ‘spin_lock’ [-Wimplicit-function-declaration]
  314 |   spin_lock(&g_ap_boot);
      |   ^~~~~~~~~
chip/intel64_cpu.c:322:3: warning: implicit declaration of function ‘spin_unlock’; did you mean ‘sched_unlock’? [-Wimplicit-function-declaration]
  322 |   spin_unlock(&g_ap_boot);
      |   ^~~~~~~~~~~

Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
chao an 2024-08-04 23:06:05 +08:00 committed by Xiang Xiao
parent 0801adb08f
commit 4ef3eeb305
2 changed files with 15 additions and 11 deletions

View File

@ -311,7 +311,9 @@ uint8_t x86_64_cpu_to_loapic(uint8_t cpu)
void x86_64_cpu_ready_set(uint8_t cpu) void x86_64_cpu_ready_set(uint8_t cpu)
{ {
spin_lock(&g_ap_boot); irqstate_t flags;
flags = spin_lock_irqsave(&g_ap_boot);
if (!g_cpu_priv[cpu].ready) if (!g_cpu_priv[cpu].ready)
{ {
@ -319,7 +321,7 @@ void x86_64_cpu_ready_set(uint8_t cpu)
g_cpu_count++; g_cpu_count++;
} }
spin_unlock(&g_ap_boot); spin_unlock_irqrestore(&g_ap_boot, flags);
} }
/**************************************************************************** /****************************************************************************
@ -333,11 +335,12 @@ void x86_64_cpu_ready_set(uint8_t cpu)
bool x86_64_cpu_ready_get(uint8_t cpu) bool x86_64_cpu_ready_get(uint8_t cpu)
{ {
struct intel64_cpu_s *priv = &g_cpu_priv[cpu]; struct intel64_cpu_s *priv = &g_cpu_priv[cpu];
irqstate_t flags;
bool ready; bool ready;
spin_lock(&g_ap_boot); flags = spin_lock_irqsave(&g_ap_boot);
ready = priv->ready; ready = priv->ready;
spin_unlock(&g_ap_boot); spin_unlock_irqrestore(&g_ap_boot, flags);
return ready; return ready;
} }
@ -352,11 +355,12 @@ bool x86_64_cpu_ready_get(uint8_t cpu)
uint8_t x86_64_cpu_count_get(void) uint8_t x86_64_cpu_count_get(void)
{ {
irqstate_t flags;
uint8_t count; uint8_t count;
spin_lock(&g_ap_boot); flags = spin_lock_irqsave(&g_ap_boot);
count = g_cpu_count; count = g_cpu_count;
spin_unlock(&g_ap_boot); spin_unlock_irqrestore(&g_ap_boot, flags);
return count; return count;
} }

View File

@ -75,7 +75,7 @@ static inline void up_idtinit(void);
static struct idt_entry_s g_idt_entries[NR_IRQS]; static struct idt_entry_s g_idt_entries[NR_IRQS];
static struct intel64_irq_priv_s g_irq_priv[NR_IRQS]; static struct intel64_irq_priv_s g_irq_priv[NR_IRQS];
static spinlock_t g_irq_spin; static spinlock_t g_irq_spinlock;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@ -482,7 +482,7 @@ void up_irqinitialize(void)
void up_disable_irq(int irq) void up_disable_irq(int irq)
{ {
#ifndef CONFIG_ARCH_INTEL64_DISABLE_INT_INIT #ifndef CONFIG_ARCH_INTEL64_DISABLE_INT_INIT
irqstate_t flags = spin_lock_irqsave(&g_irq_spin); irqstate_t flags = spin_lock_irqsave(&g_irq_spinlock);
if (irq > IRQ255) if (irq > IRQ255)
{ {
@ -508,7 +508,7 @@ void up_disable_irq(int irq)
} }
} }
spin_unlock_irqrestore(&g_irq_spin, flags); spin_unlock_irqrestore(&g_irq_spinlock, flags);
#endif #endif
} }
@ -523,7 +523,7 @@ void up_disable_irq(int irq)
void up_enable_irq(int irq) void up_enable_irq(int irq)
{ {
#ifndef CONFIG_ARCH_INTEL64_DISABLE_INT_INIT #ifndef CONFIG_ARCH_INTEL64_DISABLE_INT_INIT
irqstate_t flags = spin_lock_irqsave(&g_irq_spin); irqstate_t flags = spin_lock_irqsave(&g_irq_spinlock);
# ifndef CONFIG_IRQCHAIN # ifndef CONFIG_IRQCHAIN
/* Check if IRQ is free if we don't support IRQ chains */ /* Check if IRQ is free if we don't support IRQ chains */
@ -553,7 +553,7 @@ void up_enable_irq(int irq)
CPU_SET(up_cpu_index(), &g_irq_priv[irq].busy); CPU_SET(up_cpu_index(), &g_irq_priv[irq].busy);
spin_unlock_irqrestore(&g_irq_spin, flags); spin_unlock_irqrestore(&g_irq_spinlock, flags);
#endif #endif
} }