Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 194 → Rev 195

/SPARTAN/trunk/test/thread/thread1/test.c
0,0 → 1,71
/*
* Copyright (C) 2005 Jakub Vana
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <print.h>
#include <debug.h>
#include <panic.h>
 
#include <test.h>
#include <arch/atomic.h>
#include <proc/thread.h>
 
#include <arch.h>
 
 
 
#define THREADS 5
 
 
static void thread(void *data)
{
while(1)
{
printf("%d\n",(int)(THREAD->tid));
scheduler();
}
}
 
 
 
void test(void)
{
thread_t *t;
int i;
 
 
 
for (i=0; i<THREADS; i++)
{
if (!(t = thread_create(thread, NULL, TASK, 0)))
panic("could not create thread\n");
thread_ready(t);
}
printf("ok\n");
}
/SPARTAN/trunk/include/memstr.h
32,7 → 32,7
#include <typedefs.h>
#include <arch/types.h>
 
extern void memcopy(__address src, __address dst, size_t cnt);
extern char * memcopy(void * dst, const void *src, size_t cnt);
 
extern void memsetw(__address dst, size_t cnt, __u16 x);
extern void memsetb(__address dst, size_t cnt, __u8 x);
42,7 → 42,7
/*
* Architecture independent variants.
*/
extern void _memcopy(__address src, __address dst, size_t cnt);
extern char * _memcopy(void *dst, const void *src, size_t cnt);
extern void _memsetb(__address dst, size_t cnt, __u8 x);
 
#endif
/SPARTAN/trunk/include/cpu.h
74,6 → 74,8
extern cpu_t *cpus;
 
extern void cpu_init(void);
extern void cpu_halt(void);
 
extern void cpu_arch_init(void);
extern void cpu_identify(void);
extern void cpu_print_report(cpu_t *m);
/SPARTAN/trunk/src/Makefile.config
34,3 → 34,4
#TEST_DIR=synch/semaphore2/
#TEST_DIR=fpu/fpu1
#TEST_DIR=print/print1
TEST_DIR=thread/thread1
/SPARTAN/trunk/src/main/kinit.c
40,6 → 40,7
#include <mm/page.h>
#include <arch/mm/page.h>
#include <mm/vm.h>
#include <print.h>
 
#ifdef __SMP__
#include <arch/smp/mps.h>
/SPARTAN/trunk/src/main/uinit.c
30,7 → 30,9
#include <arch/types.h>
#include <proc/thread.h>
#include <userspace.h>
#include <print.h>
 
 
void uinit(void *arg)
{
printf("USER task, uinit thread: kernel mode\n");
/SPARTAN/trunk/src/synch/spinlock.c
31,6 → 31,7
#include <arch/atomic.h>
#include <arch/barrier.h>
#include <synch/spinlock.h>
#include <print.h>
 
#ifdef __SMP__
 
/SPARTAN/trunk/src/synch/semaphore.c
31,6 → 31,7
#include <synch/waitq.h>
#include <synch/spinlock.h>
#include <arch/asm.h>
#include <arch.h>
 
void semaphore_initialize(semaphore_t *s, int val)
{
/SPARTAN/trunk/src/debug/print.c
31,6 → 31,7
#include <synch/spinlock.h>
#include <arch/arg.h>
#include <arch/asm.h>
#include <arch.h>
 
 
static char digits[] = "0123456789abcdef"; /**< Hexadecimal characters */
/SPARTAN/trunk/src/proc/scheduler.c
43,7 → 43,11
#include <synch/spinlock.h>
#include <arch/faddr.h>
#include <arch/atomic.h>
#include <print.h>
#include <mm/frame.h>
#include <mm/heap.h>
 
 
volatile int nrdy;
 
 
357,8 → 361,9
}
THREAD = NULL;
}
 
printf("*0*");
THREAD = find_best_thread();
printf("*1*");
spinlock_lock(&THREAD->lock);
priority = THREAD->pri;
/SPARTAN/trunk/src/proc/thread.c
50,6 → 50,7
#include <smp/ipi.h>
#include <arch/faddr.h>
#include <arch/atomic.h>
#include <memstr.h>
 
char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; /**< Thread states */
 
/SPARTAN/trunk/src/lib/memstr.c
41,12 → 41,16
* @param cnt Number of bytes to copy.
*
*/
void _memcopy(__address src, __address dst, size_t cnt)
 
char * _memcopy(void * dst,const void *src, size_t cnt);
char * _memcopy(void * dst,const void *src, size_t cnt)
{
int i;
for (i=0; i<cnt; i++)
*((__u8 *) (dst + i)) = *((__u8 *) (src + i));
return (char *)src;
}
 
 
/SPARTAN/trunk/src/mm/vm.c
40,6 → 40,8
#include <panic.h>
#include <arch/asm.h>
#include <debug.h>
#include <memstr.h>
#include <arch.h>
 
#define KAS_START_INDEX PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)
#define KAS_END_INDEX PTL0_INDEX(KERNEL_ADDRESS_SPACE_END)
66,7 → 68,7
dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC);
// memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
// memcopy((__address) &src_ptl0[KAS_START_INDEX], (__address) &dst_ptl0[KAS_START_INDEX], KAS_INDICES*sizeof(pte_t));
memcopy(PA2KA((__address) GET_PTL0_ADDRESS()), (__address) dst_ptl0, PAGE_SIZE);
memcopy((void *)PA2KA((__address) dst_ptl0), (void *)GET_PTL0_ADDRESS() , PAGE_SIZE);
m->ptl0 = (pte_t *) KA2PA((__address) dst_ptl0);
}
}
/SPARTAN/trunk/src/mm/frame.c
43,6 → 43,7
#include <synch/spinlock.h>
 
#include <arch/asm.h>
#include <arch.h>
 
count_t frames = 0;
count_t frames_free;
/SPARTAN/trunk/src/mm/page.c
32,7 → 32,9
#include <arch/types.h>
#include <typedefs.h>
#include <arch/asm.h>
#include <memstr.h>
 
 
void page_init(void)
{
page_arch_init();
/SPARTAN/trunk/src/mm/heap.c
33,6 → 33,7
#include <panic.h>
#include <arch/types.h>
#include <arch/asm.h>
#include <arch.h>
 
/*
* First-fit algorithm.
/SPARTAN/trunk/arch/ppc/Makefile.inc
11,7 → 11,7
 
DEFS=-DARCH=$(ARCH)
CPPFLAGS=$(DEFS) -nostdinc -I../include
CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -Wmissing-prototypes -Werror -O2
CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O2
LFLAGS=-M -no-check-sections -T ../arch/ppc/_link.ld
 
arch_sources= \
/SPARTAN/trunk/arch/ia64/include/asm.h
47,4 → 47,9
return v;
}
 
 
void cpu_sleep(void);
 
void asm_delay_loop(__u32 t);
 
#endif
/SPARTAN/trunk/arch/ia64/Makefile.inc
11,7 → 11,7
 
DEFS=-DARCH=$(ARCH)
CPPFLAGS=$(DEFS) -nostdinc -I../include
CFLAGS=$(CPPFLAGS) -mconstant-gp -nostdlib -fno-builtin -fno-unwind-tables -Wmissing-prototypes -Werror -O3
CFLAGS=$(CPPFLAGS) -mconstant-gp -nostdlib -fno-builtin -fno-unwind-tables -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3
LFLAGS=-EL -M -T ../arch/ia64/_link.ld
 
arch_sources= \
/SPARTAN/trunk/arch/mips/include/asm.h
49,4 → 49,7
return v;
}
 
void asm_delay_loop(__u32 t);
 
 
#endif
/SPARTAN/trunk/arch/mips/Makefile.inc
11,7 → 11,7
 
DEFS=-DARCH=$(ARCH)
CPPFLAGS=$(DEFS) -mno-abicalls -nostdinc -I../include
CFLAGS=$(CPPFLAGS) -mips2 -G 0 -nostdlib -fno-builtin -Wmissing-prototypes -Werror -O2
CFLAGS=$(CPPFLAGS) -mips2 -G 0 -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O2
LFLAGS=-mips2 -M -no-check-sections -T ../arch/mips/_link.ld
 
arch_sources= \
/SPARTAN/trunk/arch/mips/src/exception.c
27,6 → 27,7
*/
 
#include <arch/exception.h>
#include <arch/interrupt.h>
#include <panic.h>
#include <arch/cp0.h>
#include <arch/types.h>
/SPARTAN/trunk/arch/mips/src/cpu/cpu.c
34,6 → 34,7
#include <arch/cp0.h>
 
#include <typedefs.h>
#include <print.h>
 
struct {
char *vendor;
/SPARTAN/trunk/arch/mips/src/mm/tlb.c
33,6 → 33,11
#include <panic.h>
#include <arch.h>
 
void main_bsp(void);
 
 
 
 
int bootstrap = 1;
 
void tlb_refill(void)
/SPARTAN/trunk/arch/mips/src/mm/page.c
31,6 → 31,7
#include <arch/mm/frame.h>
#include <mm/frame.h>
#include <mm/page.h>
#include <memstr.h>
 
pte_t *PTL0 = NULL;
 
/SPARTAN/trunk/arch/amd64/Makefile.inc
10,7 → 10,7
 
DEFS=-DARCH=$(ARCH)
CPPFLAGS=$(DEFS) -nostdinc -I../include
CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fno-unwind-tables -Wmissing-prototypes -Werror -O3 -march=opteron -m64 -mcmodel=kernel -mno-red-zone
CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fno-unwind-tables -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -march=opteron -m64 -mcmodel=kernel -mno-red-zone
LFLAGS=-M -T ../arch/amd64/_link.ld
 
arch_sources = arch/dummy.s \
/SPARTAN/trunk/arch/ia32/include/asm.h
52,6 → 52,11
 
extern void enable_l_apic_in_msr(void);
 
 
void asm_delay_loop(__u32 t);
void asm_fake_loop(__u32 t);
 
 
/** Halt CPU
*
* Halt the current CPU until interrupt event.
/SPARTAN/trunk/arch/ia32/Makefile.inc
13,7 → 13,7
endif
 
CPPFLAGS=$(DEFS) -nostdinc -I../include
CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Wmissing-prototypes -Werror -O3
CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3
LFLAGS=-M -no-check-sections -T ../arch/ia32/_link.ld
 
arch_sources= \
/SPARTAN/trunk/arch/ia32/src/ia32.c
45,8 → 45,12
#include <arch/interrupt.h>
#include <arch/asm.h>
#include <arch/acpi/acpi.h>
 
#include <arch/bios/bios.h>
 
#include <arch/mm/memory_init.h>
 
 
void arch_pre_mm_init(void)
{
pm_init();
/SPARTAN/trunk/arch/ia32/src/pm.c
35,6 → 35,8
#include <arch/context.h>
#include <panic.h>
#include <arch/mm/page.h>
#include <mm/heap.h>
#include <memstr.h>
 
/*
* Early ia32 configuration functions and data structures.
/SPARTAN/trunk/arch/ia32/src/smp/mps.c
40,6 → 40,7
#include <cpu.h>
#include <arch/asm.h>
#include <arch/bios/bios.h>
#include <mm/frame.h>
 
/*
* MultiProcessor Specification detection code.
/SPARTAN/trunk/arch/ia32/src/smp/smp.c
42,6 → 42,9
#include <mm/frame.h>
#include <mm/page.h>
#include <mm/heap.h>
#include <print.h>
#include <memstr.h>
#include <arch/i8259.h>
 
#ifdef __SMP__
 
136,8 → 139,8
if (!(gdt_new = (struct descriptor *) malloc(GDT_ITEMS*sizeof(struct descriptor))))
panic("couldn't allocate memory for GDT\n");
 
memcopy(gdt, gdt_new, GDT_ITEMS*sizeof(struct descriptor));
memsetb(&gdt_new[TSS_DES], sizeof(struct descriptor), 0);
memcopy(gdt_new, gdt, GDT_ITEMS*sizeof(struct descriptor)); // swaped
memsetb((__address)(&gdt_new[TSS_DES]), sizeof(struct descriptor), 0);
gdtr.base = KA2PA((__address) gdt_new);
 
if (l_apic_send_init_ipi(ops->cpu_apic_id(i))) {
/SPARTAN/trunk/arch/ia32/src/mm/memory_init.c
28,6 → 28,7
 
#include <arch/boot/memmap.h>
#include <arch/mm/memory_init.h>
#include <print.h>
 
size_t get_memory_size(void)
{
/SPARTAN/trunk/arch/ia32/src/mm/page.c
36,6 → 36,7
#include <arch/asm.h>
#include <synch/spinlock.h>
#include <debug.h>
#include <memstr.h>
 
__address bootstrap_dba;
 
71,7 → 72,7
*/
 
dba = frame_alloc(FRAME_KA | FRAME_PANIC);
memcopy(bootstrap_dba, dba, PAGE_SIZE);
memcopy((void *)dba,(void *)bootstrap_dba , PAGE_SIZE); //swaped
write_cr3(KA2PA(dba));
}
 
/SPARTAN/trunk/arch/ia32/src/acpi/madt.c
35,6 → 35,7
#include <panic.h>
#include <debug.h>
#include <config.h>
#include <print.h>
 
struct acpi_madt *acpi_madt = NULL;
 
/SPARTAN/trunk/arch/ia32/src/acpi/acpi.c
31,6 → 31,7
#include <arch/bios/bios.h>
 
#include <mm/page.h>
#include <print.h>
 
#define RSDP_SIGNATURE "RSD PTR "
#define RSDP_REVISION_OFFS 15
/SPARTAN/trunk/arch/ia32/src/drivers/i8259.c
31,6 → 31,7
#include <arch/types.h>
#include <arch/asm.h>
#include <arch.h>
#include <print.h>
 
/*
* This is the PIC driver.
/SPARTAN/trunk/arch/ia32/src/drivers/i8254.c
36,7 → 36,9
#include <config.h>
#include <arch/pm.h>
#include <arch/asm.h>
#include <arch/cpuid.h>
#include <arch.h>
#include <time/delay.h>
 
/*
* i8254 chip driver.
/SPARTAN/trunk/arch/ia32/src/drivers/ega.c
33,6 → 33,7
#include <synch/spinlock.h>
#include <arch/types.h>
#include <arch/asm.h>
#include <memstr.h>
 
/*
* The EGA driver.
72,7 → 73,7
if (ega_cursor < SCREEN)
return;
 
memcopy(PA2KA(VIDEORAM) + ROW*2, PA2KA(VIDEORAM), (SCREEN - ROW)*2);
memcopy((void *)PA2KA(VIDEORAM),(void *)PA2KA(VIDEORAM) + ROW*2, (SCREEN - ROW)*2); //swaped
memsetw(PA2KA(VIDEORAM) + (SCREEN - ROW)*2, ROW, 0x0720);
ega_cursor = ega_cursor - ROW;
}