Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3480 → Rev 3482

/drivers/ddk/Makefile
1,4 → 1,5
 
 
CC = gcc
AS = as
 
7,7 → 8,7
 
INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_INCLUDES)/linux -I$(DRV_INCLUDES)/linux/asm
DEFINES = -DKOLIBRI -D__KERNEL__ -DCONFIG_X86_32
CFLAGS = -c -Os $(INCLUDES) $(DEFINES) -march=i586 -fomit-frame-pointer -fno-builtin-printf \
CFLAGS = -c -Os $(INCLUDES) $(DEFINES) -march=i686 -fomit-frame-pointer -fno-builtin-printf \
-mno-stack-arg-probe -mpreferred-stack-boundary=2 -mincoming-stack-boundary=2
 
NAME:= libddk
31,6 → 32,7
linux/ctype.c \
linux/string.c \
linux/time.c \
linux/workqueue.c \
malloc/malloc.c \
stdio/vsprintf.c \
string/_memmove.S \
/drivers/ddk/core.S
24,13 → 24,14
.global _FreeKernelSpace
.global _FreePage
 
.global _GetCpuFreq
.global _GetDisplay
.global _GetEvent
.global _GetPgAddr
.global _GetPid
.global _GetService
.global _GetStackBase
.global _GetTimerTicks
.global _GetStackBase
.global _GetWindowRect
 
.global _KernelAlloc
92,6 → 93,8
.def _FreePage; .scl 2; .type 32; .endef
 
.def _GetDisplay; .scl 2; .type 32; .endef
 
.def _GetDisplay; .scl 2; .type 32; .endef
.def _GetEvent; .scl 2; .type 32; .endef
.def _GetPid; .scl 2; .type 32; .endef
.def _GetPgAddr; .scl 2; .type 32; .endef
158,6 → 161,7
_FreeKernelSpace:
_FreePage:
 
_GetCpuFreq:
_GetDisplay:
_GetEvent:
_GetPid:
229,6 → 233,8
.ascii " -export:FreeKernelSpace" # stdcall
.ascii " -export:FreePage" #
 
.ascii " -export:GetCpuFreq" #
 
.ascii " -export:GetDisplay" # stdcall
.ascii " -export:GetEvent" #
.ascii " -export:GetPid" #
/drivers/ddk/linux/workqueue.c
0,0 → 1,105
#include <linux/kernel.h>
#include <linux/workqueue.h>
#include <ddk.h>
 
struct workqueue_struct *alloc_workqueue(const char *fmt,
unsigned int flags,
int max_active)
{
struct workqueue_struct *wq;
 
wq = kzalloc(sizeof(*wq),0);
if (!wq)
goto err;
 
INIT_LIST_HEAD(&wq->worklist);
INIT_LIST_HEAD(&wq->delayed_worklist);
 
return wq;
err:
return NULL;
}
 
 
 
void run_workqueue(struct workqueue_struct *cwq)
{
unsigned long irqflags;
 
// dbgprintf("wq: %x head %x, next %x\n",
// cwq, &cwq->worklist, cwq->worklist.next);
 
repeat:
 
spin_lock_irqsave(&cwq->lock, irqflags);
 
while (!list_empty(&cwq->worklist))
{
struct work_struct *work = list_entry(cwq->worklist.next,
struct work_struct, entry);
work_func_t f = work->func;
list_del_init(cwq->worklist.next);
// dbgprintf("head %x, next %x\n",
// &cwq->worklist, cwq->worklist.next);
 
spin_unlock_irqrestore(&cwq->lock, irqflags);
f(work);
spin_lock_irqsave(&cwq->lock, irqflags);
}
 
spin_unlock_irqrestore(&cwq->lock, irqflags);
 
delay(1);
 
goto repeat;
}
 
 
bool queue_work(struct workqueue_struct *wq, struct work_struct *work)
{
unsigned long flags;
 
if(!list_empty(&work->entry))
return 0;
 
// dbgprintf("%s %p queue: %p\n", __FUNCTION__, work, wq);
 
spin_lock_irqsave(&wq->lock, flags);
 
list_add_tail(&work->entry, &wq->worklist);
 
spin_unlock_irqrestore(&wq->lock, flags);
 
return 1;
};
 
 
void __stdcall delayed_work_timer_fn(unsigned long __data)
{
struct delayed_work *dwork = (struct delayed_work *)__data;
struct workqueue_struct *wq = dwork->work.data;
 
queue_work(wq, &dwork->work);
}
 
int queue_delayed_work(struct workqueue_struct *wq,
struct delayed_work *dwork, unsigned long delay)
{
struct work_struct *work = &dwork->work;
 
if (delay == 0)
return queue_work(wq, &dwork->work);
 
// dbgprintf("%s %p queue: %p\n", __FUNCTION__, &dwork->work, wq);
 
work->data = wq;
TimerHs(delay,0, delayed_work_timer_fn, dwork);
return 1;
}
 
 
bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay)
{
return queue_delayed_work(system_wq, dwork, delay);
}