ioapic.c 784 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/io.h>
  8. #include <asm/ioapic.h>
  9. #include <asm/lapic.h>
  10. u32 io_apic_read(u32 reg)
  11. {
  12. writel(reg, IO_APIC_INDEX);
  13. return readl(IO_APIC_DATA);
  14. }
  15. void io_apic_write(u32 reg, u32 val)
  16. {
  17. writel(reg, IO_APIC_INDEX);
  18. writel(val, IO_APIC_DATA);
  19. }
  20. void io_apic_set_id(int ioapic_id)
  21. {
  22. int bsp_lapicid = lapicid();
  23. debug("IOAPIC: Initialising IOAPIC at %08x\n", IO_APIC_ADDR);
  24. debug("IOAPIC: Bootstrap Processor Local APIC = %#02x\n", bsp_lapicid);
  25. if (ioapic_id) {
  26. debug("IOAPIC: ID = 0x%02x\n", ioapic_id);
  27. /* Set IOAPIC ID if it has been specified */
  28. io_apic_write(0x00, (io_apic_read(0x00) & 0xf0ffffff) |
  29. (ioapic_id << 24));
  30. }
  31. }