Merge branch 'scheduler'
Conflicts: build/jam/packages/Haiku headers/os/kernel/OS.h headers/os/opengl/GLRenderer.h headers/private/shared/cpu_type.h src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.h src/bin/sysinfo.cpp src/bin/top.c src/system/kernel/arch/x86/arch_system_info.cpp src/system/kernel/port.cpp
This commit is contained in:
@@ -20,9 +20,9 @@ typedef ulong cpu_status;
|
||||
|
||||
#if B_DEBUG_SPINLOCK_CONTENTION
|
||||
typedef struct {
|
||||
vint32 lock;
|
||||
vint32 count_low;
|
||||
vint32 count_high;
|
||||
int32 lock;
|
||||
int32 count_low;
|
||||
int32 count_high;
|
||||
} spinlock;
|
||||
|
||||
# define B_SPINLOCK_INITIALIZER { 0, 0, 0 }
|
||||
@@ -31,15 +31,39 @@ typedef ulong cpu_status;
|
||||
(spinlock)->count_low = 0; \
|
||||
(spinlock)->count_high = 0; \
|
||||
} while (false)
|
||||
# define B_SPINLOCK_IS_LOCKED(spinlock) ((spinlock)->lock > 0)
|
||||
#else
|
||||
typedef vint32 spinlock;
|
||||
typedef struct {
|
||||
int32 lock;
|
||||
} spinlock;
|
||||
|
||||
# define B_SPINLOCK_INITIALIZER 0
|
||||
# define B_INITIALIZE_SPINLOCK(lock) do { *(lock) = 0; } while (false)
|
||||
# define B_SPINLOCK_IS_LOCKED(lock) (*(lock) > 0)
|
||||
# define B_SPINLOCK_INITIALIZER { 0 }
|
||||
# define B_INITIALIZE_SPINLOCK(spinlock) do { \
|
||||
(spinlock)->lock = 0; \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
#define B_SPINLOCK_IS_LOCKED(spinlock) (atomic_get(&(spinlock)->lock) > 0)
|
||||
|
||||
typedef struct {
|
||||
int32 lock;
|
||||
} rw_spinlock;
|
||||
|
||||
#define B_RW_SPINLOCK_INITIALIZER { 0 }
|
||||
#define B_INITIALIZE_RW_SPINLOCK(rw_spinlock) do { \
|
||||
(rw_spinlock)->lock = 0; \
|
||||
} while (false)
|
||||
|
||||
typedef struct {
|
||||
spinlock lock;
|
||||
uint32 count;
|
||||
} seqlock;
|
||||
|
||||
#define B_SEQLOCK_INITIALIZER { B_SPINLOCK_INITIALIZER, 0 }
|
||||
#define B_INITIALIZE_SEQLOCK(seqlock) do { \
|
||||
B_INITIALIZE_SPINLOCK(&(seqlock)->lock); \
|
||||
(seqlock)->count = 0; \
|
||||
} while (false)
|
||||
|
||||
/* interrupt handling support for device drivers */
|
||||
|
||||
typedef int32 (*interrupt_handler)(void *data);
|
||||
@@ -126,6 +150,19 @@ extern void restore_interrupts(cpu_status status);
|
||||
extern void acquire_spinlock(spinlock *lock);
|
||||
extern void release_spinlock(spinlock *lock);
|
||||
|
||||
extern bool try_acquire_write_spinlock(rw_spinlock* lock);
|
||||
extern void acquire_write_spinlock(rw_spinlock* lock);
|
||||
extern void release_write_spinlock(rw_spinlock* lock);
|
||||
extern bool try_acquire_read_spinlock(rw_spinlock* lock);
|
||||
extern void acquire_read_spinlock(rw_spinlock* lock);
|
||||
extern void release_read_spinlock(rw_spinlock* lock);
|
||||
|
||||
extern bool try_acquire_write_seqlock(seqlock* lock);
|
||||
extern void acquire_write_seqlock(seqlock* lock);
|
||||
extern void release_write_seqlock(seqlock* lock);
|
||||
extern uint32 acquire_read_seqlock(seqlock* lock);
|
||||
extern bool release_read_seqlock(seqlock* lock, uint32 count);
|
||||
|
||||
extern status_t install_io_interrupt_handler(long interrupt_number,
|
||||
interrupt_handler handler, void *data, ulong flags);
|
||||
extern status_t remove_io_interrupt_handler(long interrupt_number,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _CPUFREQ_H
|
||||
#define _CPUFREQ_H
|
||||
|
||||
|
||||
#include <module.h>
|
||||
|
||||
#include <scheduler.h>
|
||||
|
||||
|
||||
#define CPUFREQ_MODULES_PREFIX "power/cpufreq"
|
||||
|
||||
|
||||
const int kCPUPerformanceScaleMax = 1000;
|
||||
|
||||
typedef struct cpufreq_module_info {
|
||||
module_info info;
|
||||
|
||||
float rank;
|
||||
|
||||
void (*cpufreq_set_scheduler_mode)(enum scheduler_mode mode);
|
||||
|
||||
status_t (*cpufreq_increase_performance)(int delta);
|
||||
status_t (*cpufreq_decrease_performance)(int delta);
|
||||
} cpufreq_module_info;
|
||||
|
||||
|
||||
#endif // _CPUFREQ_H
|
||||
|
||||
@@ -8,50 +8,22 @@
|
||||
|
||||
#include <module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CPUIDLE_CSTATE_MAX 8
|
||||
#define CSTATE_NAME_LENGTH 32
|
||||
#define B_CPUIDLE_MODULE_NAME "generic/cpuidle/v1"
|
||||
#include <scheduler.h>
|
||||
|
||||
|
||||
struct CpuidleStat {
|
||||
uint64 usageCount;
|
||||
bigtime_t usageTime;
|
||||
};
|
||||
#define CPUIDLE_MODULES_PREFIX "power/cpuidle"
|
||||
|
||||
|
||||
struct CpuidleInfo {
|
||||
int32 cstateSleep;
|
||||
CpuidleStat stats[CPUIDLE_CSTATE_MAX];
|
||||
};
|
||||
typedef struct cpuidle_module_info {
|
||||
module_info info;
|
||||
|
||||
struct CpuidleDevice;
|
||||
float rank;
|
||||
|
||||
struct CpuidleCstate {
|
||||
char name[CSTATE_NAME_LENGTH];
|
||||
int32 latency;
|
||||
int32 (*EnterIdle)(int32 state, CpuidleDevice *device);
|
||||
void *pData;
|
||||
};
|
||||
void (*cpuidle_set_scheduler_mode)(enum scheduler_mode mode);
|
||||
|
||||
void (*cpuidle_idle)(void);
|
||||
void (*cpuidle_wait)(int32* variable, int32 test);
|
||||
} cpuidle_module_info;
|
||||
|
||||
struct CpuidleDevice {
|
||||
CpuidleCstate cStates[CPUIDLE_CSTATE_MAX];
|
||||
int32 cStateCount;
|
||||
};
|
||||
|
||||
|
||||
struct CpuidleModuleInfo {
|
||||
module_info info;
|
||||
status_t (*AddDevice)(CpuidleDevice *device);
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _CPUIDLE_MODULE_H
|
||||
|
||||
Reference in New Issue
Block a user