diff options
-rw-r--r-- | src/apm.c | 1 | ||||
-rw-r--r-- | src/block.c | 1 | ||||
-rw-r--r-- | src/bootsplash.c | 1 | ||||
-rw-r--r-- | src/clock.c | 1 | ||||
-rw-r--r-- | src/disk.c | 1 | ||||
-rw-r--r-- | src/fw/coreboot.c | 1 | ||||
-rw-r--r-- | src/fw/csm.c | 1 | ||||
-rw-r--r-- | src/fw/smp.c | 1 | ||||
-rw-r--r-- | src/hw/ahci.c | 1 | ||||
-rw-r--r-- | src/hw/ata.c | 1 | ||||
-rw-r--r-- | src/hw/floppy.c | 1 | ||||
-rw-r--r-- | src/hw/megasas.c | 1 | ||||
-rw-r--r-- | src/hw/pci.c | 1 | ||||
-rw-r--r-- | src/hw/ps2port.c | 1 | ||||
-rw-r--r-- | src/hw/ramdisk.c | 1 | ||||
-rw-r--r-- | src/hw/timer.c | 1 | ||||
-rw-r--r-- | src/hw/usb.h | 2 | ||||
-rw-r--r-- | src/kbd.c | 1 | ||||
-rw-r--r-- | src/misc.c | 1 | ||||
-rw-r--r-- | src/mouse.c | 1 | ||||
-rw-r--r-- | src/optionroms.c | 1 | ||||
-rw-r--r-- | src/output.c | 1 | ||||
-rw-r--r-- | src/pmm.c | 1 | ||||
-rw-r--r-- | src/resume.c | 1 | ||||
-rw-r--r-- | src/serial.c | 1 | ||||
-rw-r--r-- | src/stacks.c | 1 | ||||
-rw-r--r-- | src/stacks.h | 34 | ||||
-rw-r--r-- | src/string.c | 2 | ||||
-rw-r--r-- | src/util.h | 28 |
29 files changed, 62 insertions, 29 deletions
@@ -13,6 +13,7 @@ #include "biosvar.h" // GET_GLOBAL #include "fw/paravirt.h" // runningOnQEMU #include "fw/acpi.h" // acpi_pm_ctl +#include "stacks.h" // yield_toirq static void out_str(const char *str_cs) diff --git a/src/block.c b/src/block.c index c6e4167e..9cfd7dd2 100644 --- a/src/block.c +++ b/src/block.c @@ -13,6 +13,7 @@ #include "hw/ahci.h" // process_ahci_op #include "hw/virtio-blk.h" // process_virtio_blk_op #include "hw/blockcmd.h" // cdb_* +#include "stacks.h" // stack_hop #include "string.h" // checksum u8 FloppyCount VARFSEG; diff --git a/src/bootsplash.c b/src/bootsplash.c index f4f8ea90..340839b0 100644 --- a/src/bootsplash.c +++ b/src/bootsplash.c @@ -13,6 +13,7 @@ #include "vbe.h" // struct vbe_info #include "bmp.h" // bmp_alloc #include "fw/smbios.h" // display_uuid +#include "stacks.h" // call16_int #include "string.h" // memset diff --git a/src/clock.c b/src/clock.c index fc91db77..6b27aa9c 100644 --- a/src/clock.c +++ b/src/clock.c @@ -14,6 +14,7 @@ #include "bregs.h" // struct bregs #include "biosvar.h" // GET_GLOBAL #include "hw/usb-hid.h" // usb_check_event +#include "stacks.h" // yield #include "string.h" // memset // RTC register flags @@ -13,6 +13,7 @@ #include "bregs.h" // struct bregs #include "hw/pci.h" // pci_bdf_to_bus #include "hw/ata.h" // ATA_CB_DC +#include "stacks.h" // call16_int #include "string.h" // memset diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c index 6da90b58..c67a62b4 100644 --- a/src/fw/coreboot.c +++ b/src/fw/coreboot.c @@ -15,6 +15,7 @@ #include "acpi.h" // find_acpi_features #include "hw/pci.h" // pci_probe_devices #include "paravirt.h" // PlatformRunningOn +#include "stacks.h" // yield #include "string.h" // memset diff --git a/src/fw/csm.c b/src/fw/csm.c index 4a78bacc..81159b3f 100644 --- a/src/fw/csm.c +++ b/src/fw/csm.c @@ -17,6 +17,7 @@ #include "boot.h" #include "smbios.h" #include "hw/pic.h" +#include "stacks.h" // wait_threads struct rsdp_descriptor csm_rsdp VARFSEG __aligned(16); diff --git a/src/fw/smp.c b/src/fw/smp.c index a8504abb..19062552 100644 --- a/src/fw/smp.c +++ b/src/fw/smp.c @@ -8,6 +8,7 @@ #include "util.h" // dprintf #include "config.h" // CONFIG_* #include "hw/cmos.h" // CMOS_BIOS_SMP_COUNT +#include "stacks.h" // yield #include "x86.h" // wrmsr #define APIC_ICR_LOW ((u8*)BUILD_APIC_ADDR + 0x300) diff --git a/src/hw/ahci.c b/src/hw/ahci.c index 297351a8..1fa1d3e0 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -16,6 +16,7 @@ #include "ata.h" // ATA_CB_STAT #include "ahci.h" // CDB_CMD_READ_10 #include "blockcmd.h" // CDB_CMD_READ_10 +#include "stacks.h" // yield #include "string.h" // memset #define AHCI_REQUEST_TIMEOUT 32000 // 32 seconds max for IDE ops diff --git a/src/hw/ata.c b/src/hw/ata.c index 705e106e..5e9b9058 100644 --- a/src/hw/ata.c +++ b/src/hw/ata.c @@ -19,6 +19,7 @@ #include "disk.h" // struct ata_s #include "ata.h" // ATA_CB_STAT #include "blockcmd.h" // CDB_CMD_READ_10 +#include "stacks.h" // yield #include "string.h" // memset #define IDE_TIMEOUT 32000 //32 seconds max for IDE ops diff --git a/src/hw/floppy.c b/src/hw/floppy.c index ae66bc0c..c051f544 100644 --- a/src/hw/floppy.c +++ b/src/hw/floppy.c @@ -16,6 +16,7 @@ #include "boot.h" // boot_add_floppy #include "pci.h" // pci_to_bdf #include "pci_ids.h" // PCI_CLASS_BRIDGE_ISA +#include "stacks.h" // yield #include "string.h" // memset #define FLOPPY_SIZE_CODE 0x02 // 512 byte sectors diff --git a/src/hw/megasas.c b/src/hw/megasas.c index 144fb840..19ed1b47 100644 --- a/src/hw/megasas.c +++ b/src/hw/megasas.c @@ -19,6 +19,7 @@ #include "boot.h" // bootprio_find_scsi_device #include "blockcmd.h" // scsi_drive_setup #include "disk.h" +#include "stacks.h" // yield #include "string.h" // memset #define MFI_DB 0x0 // Doorbell diff --git a/src/hw/pci.c b/src/hw/pci.c index 7fdde2a5..295a26d7 100644 --- a/src/hw/pci.c +++ b/src/hw/pci.c @@ -12,6 +12,7 @@ #include "farptr.h" // MAKE_FLATPTR #include "pci_regs.h" // PCI_VENDOR_ID #include "pci_ids.h" // PCI_CLASS_DISPLAY_VGA +#include "stacks.h" // call32 #include "string.h" // memset #include "x86.h" // readl diff --git a/src/hw/ps2port.c b/src/hw/ps2port.c index 4b6c5df9..6fd0c3a6 100644 --- a/src/hw/ps2port.c +++ b/src/hw/ps2port.c @@ -10,6 +10,7 @@ #include "biosvar.h" // GET_LOW #include "ps2port.h" // ps2_kbd_command #include "pic.h" // pic_eoi1 +#include "stacks.h" // yield /**************************************************************** diff --git a/src/hw/ramdisk.c b/src/hw/ramdisk.c index 6e730bfe..cd517e76 100644 --- a/src/hw/ramdisk.c +++ b/src/hw/ramdisk.c @@ -10,6 +10,7 @@ #include "biosvar.h" // GET_GLOBAL #include "bregs.h" // struct bregs #include "boot.h" // boot_add_floppy +#include "stacks.h" // call16_int #include "string.h" // memset void diff --git a/src/hw/timer.c b/src/hw/timer.c index 2547639d..56c4eca6 100644 --- a/src/hw/timer.c +++ b/src/hw/timer.c @@ -9,6 +9,7 @@ #include "ioport.h" // PORT_PIT_MODE #include "config.h" // CONFIG_* #include "biosvar.h" // GET_LOW +#include "stacks.h" // yield #include "x86.h" // cpuid // Bits for PORT_PS2_CTRLB diff --git a/src/hw/usb.h b/src/hw/usb.h index a43e8299..1ac86c78 100644 --- a/src/hw/usb.h +++ b/src/hw/usb.h @@ -2,7 +2,7 @@ #ifndef __USB_H #define __USB_H -#include "util.h" // struct mutex_s +#include "stacks.h" // struct mutex_s // Information on a USB end point. struct usb_pipe { @@ -11,6 +11,7 @@ #include "bregs.h" // struct bregs #include "hw/ps2port.h" // ps2_kbd_command #include "hw/usb-hid.h" // usb_kbd_command +#include "stacks.h" // stack_hop #include "string.h" // memset // Bit definitions for BDA kbd_flag[012] @@ -9,6 +9,7 @@ #include "biosvar.h" // GET_BDA #include "util.h" // debug_enter #include "hw/pic.h" // enable_hwirq +#include "stacks.h" // call16_int #include "string.h" // memset diff --git a/src/mouse.c b/src/mouse.c index 5a7ae0a1..8e8374cd 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -10,6 +10,7 @@ #include "bregs.h" // struct bregs #include "hw/ps2port.h" // ps2_mouse_command #include "hw/usb-hid.h" // usb_mouse_command +#include "stacks.h" // stack_hop void mouse_init(void) diff --git a/src/optionroms.c b/src/optionroms.c index 8288e5fa..cc6083b4 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -14,6 +14,7 @@ #include "hw/pci_ids.h" // PCI_CLASS_DISPLAY_VGA #include "boot.h" // IPL #include "optionroms.h" // struct rom_header +#include "stacks.h" // farcall16big #include "string.h" // memset diff --git a/src/output.c b/src/output.c index 918a6edb..b5d7ae09 100644 --- a/src/output.c +++ b/src/output.c @@ -12,6 +12,7 @@ #include "config.h" // CONFIG_* #include "biosvar.h" // GET_GLOBAL #include "fw/paravirt.h" // PlatformRunningOn +#include "stacks.h" // call16_int #include "string.h" // memset struct putcinfo { @@ -11,6 +11,7 @@ #include "biosvar.h" // GET_BDA #include "optionroms.h" // OPTION_ROM_ALIGN #include "list.h" // hlist_node +#include "stacks.h" // wait_preempt #include "string.h" // memset #include "x86.h" // __ffs diff --git a/src/resume.c b/src/resume.c index 7fb4a759..892c76c3 100644 --- a/src/resume.c +++ b/src/resume.c @@ -13,6 +13,7 @@ #include "hw/ps2port.h" // i8042_reboot #include "hw/pci.h" // pci_reboot #include "hw/cmos.h" // inb_cmos +#include "stacks.h" // farcall16big #include "string.h" // memset // Indicator if POST phase has been run. diff --git a/src/serial.c b/src/serial.c index b4a0a533..8fd3067a 100644 --- a/src/serial.c +++ b/src/serial.c @@ -8,6 +8,7 @@ #include "biosvar.h" // SET_BDA #include "util.h" // debug_enter #include "bregs.h" // struct bregs +#include "stacks.h" // yield /**************************************************************** diff --git a/src/stacks.c b/src/stacks.c index ac75497a..b499872a 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -8,6 +8,7 @@ #include "util.h" // dprintf #include "bregs.h" // CR0_PE #include "list.h" // hlist_node +#include "stacks.h" // struct mutex_s /**************************************************************** diff --git a/src/stacks.h b/src/stacks.h new file mode 100644 index 00000000..5ee4adc3 --- /dev/null +++ b/src/stacks.h @@ -0,0 +1,34 @@ +// Misc function and variable declarations. +#ifndef __STACKS_H +#define __STACKS_H + +#include "types.h" // u32 + +// stacks.c +extern u8 ExtraStack[], *StackPos; +u32 stack_hop(u32 eax, u32 edx, void *func); +u32 stack_hop_back(u32 eax, u32 edx, void *func); +u32 call32(void *func, u32 eax, u32 errret); +struct bregs; +inline void farcall16(struct bregs *callregs); +inline void farcall16big(struct bregs *callregs); +inline void __call16_int(struct bregs *callregs, u16 offset); +#define call16_int(nr, callregs) do { \ + extern void irq_trampoline_ ##nr (); \ + __call16_int((callregs), (u32)&irq_trampoline_ ##nr ); \ + } while (0) +extern struct thread_info MainThread; +struct thread_info *getCurThread(void); +void yield(void); +void yield_toirq(void); +void run_thread(void (*func)(void*), void *data); +void wait_threads(void); +struct mutex_s { u32 isLocked; }; +void mutex_lock(struct mutex_s *mutex); +void mutex_unlock(struct mutex_s *mutex); +void start_preempt(void); +void finish_preempt(void); +int wait_preempt(void); +void check_preempt(void); + +#endif // stacks.h diff --git a/src/string.c b/src/string.c index 5f2dede9..574c13e7 100644 --- a/src/string.c +++ b/src/string.c @@ -4,7 +4,7 @@ // // This file may be distributed under the terms of the GNU LGPLv3 license. -#include "util.h" // yield +#include "stacks.h" // yield #include "string.h" // memcpy #include "farptr.h" // SET_SEG @@ -4,33 +4,6 @@ #include "types.h" // u32 -// stacks.c -extern u8 ExtraStack[], *StackPos; -u32 stack_hop(u32 eax, u32 edx, void *func); -u32 stack_hop_back(u32 eax, u32 edx, void *func); -u32 call32(void *func, u32 eax, u32 errret); -struct bregs; -inline void farcall16(struct bregs *callregs); -inline void farcall16big(struct bregs *callregs); -inline void __call16_int(struct bregs *callregs, u16 offset); -#define call16_int(nr, callregs) do { \ - extern void irq_trampoline_ ##nr (); \ - __call16_int((callregs), (u32)&irq_trampoline_ ##nr ); \ - } while (0) -extern struct thread_info MainThread; -struct thread_info *getCurThread(void); -void yield(void); -void yield_toirq(void); -void run_thread(void (*func)(void*), void *data); -void wait_threads(void); -struct mutex_s { u32 isLocked; }; -void mutex_lock(struct mutex_s *mutex); -void mutex_unlock(struct mutex_s *mutex); -void start_preempt(void); -void finish_preempt(void); -int wait_preempt(void); -void check_preempt(void); - // output.c extern u16 DebugOutputPort; void debug_serial_preinit(void); @@ -44,6 +17,7 @@ char * znprintf(size_t size, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void __dprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +struct bregs; void __debug_enter(struct bregs *regs, const char *fname); void __debug_isr(const char *fname); void __debug_stub(struct bregs *regs, int lineno, const char *fname); |