Skip to content

Commit

Permalink
arch/x86_64: fix build break if disable CONFIG_SPINLOCK
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
anchao authored and xiaoxiang781216 committed Aug 5, 2024
1 parent 0801adb commit 4ef3eeb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 10 additions & 6 deletions arch/x86_64/src/intel64/intel64_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,17 @@ uint8_t x86_64_cpu_to_loapic(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)
{
g_cpu_priv[cpu].ready = true;
g_cpu_count++;
}

spin_unlock(&g_ap_boot);
spin_unlock_irqrestore(&g_ap_boot, flags);
}

/****************************************************************************
Expand All @@ -333,11 +335,12 @@ void x86_64_cpu_ready_set(uint8_t cpu)
bool x86_64_cpu_ready_get(uint8_t cpu)
{
struct intel64_cpu_s *priv = &g_cpu_priv[cpu];
irqstate_t flags;
bool ready;

spin_lock(&g_ap_boot);
flags = spin_lock_irqsave(&g_ap_boot);
ready = priv->ready;
spin_unlock(&g_ap_boot);
spin_unlock_irqrestore(&g_ap_boot, flags);

return ready;
}
Expand All @@ -352,11 +355,12 @@ bool x86_64_cpu_ready_get(uint8_t cpu)

uint8_t x86_64_cpu_count_get(void)
{
irqstate_t flags;
uint8_t count;

spin_lock(&g_ap_boot);
flags = spin_lock_irqsave(&g_ap_boot);
count = g_cpu_count;
spin_unlock(&g_ap_boot);
spin_unlock_irqrestore(&g_ap_boot, flags);

return count;
}
Expand Down
10 changes: 5 additions & 5 deletions arch/x86_64/src/intel64/intel64_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static inline void up_idtinit(void);

static struct idt_entry_s g_idt_entries[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
Expand Down Expand Up @@ -482,7 +482,7 @@ void up_irqinitialize(void)
void up_disable_irq(int irq)
{
#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)
{
Expand All @@ -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
}

Expand All @@ -523,7 +523,7 @@ void up_disable_irq(int irq)
void up_enable_irq(int irq)
{
#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
/* Check if IRQ is free if we don't support IRQ chains */
Expand Down Expand Up @@ -553,7 +553,7 @@ void up_enable_irq(int irq)

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
}

Expand Down

0 comments on commit 4ef3eeb

Please sign in to comment.