galileo: Concentrate core implementations in platform/galileo/core/
Currently, it is common to see Contiki's core/ interfaces implementations spread in both cpu/ and platform/. We here take one step further starting an effort to centralize all of these in platform's code instead. This commit starts this by adding platform/galileo/core/ and its sys/ subfolder, adding a stubbed mtarch.h and moving clock and rtimer implementations to this new folder. From now on we should concentrate implementation from Contiki's core/ interfaces into the appropriate subfolder in platform/galileo/core/. Note that this is not the current fashion followed on other platforms and cpus folders, as most of them add the core interface implementation into its subfolder directly. For instance, on CC2538DK, core/dev/button-sensor.h is implemented in platform/cc2538dk/dev/ directly, while on Galileo it would sit at platform/galileo/core/dev/. We believe ours is a better approach to organize and escalate a platform's code base. We also remove previous x86 mtarch.h and mtarch.c since they weren't used at all - both native and cooja platforms have their own mtarch implementations.
This commit is contained in:
parent
568f565b3d
commit
9d3b9cadc4
8 changed files with 39 additions and 239 deletions
|
@ -1,6 +1,6 @@
|
|||
CONTIKI_CPU_DIRS = . drivers
|
||||
|
||||
CONTIKI_SOURCEFILES += mtarch.c gdt.c helpers.S idt.c cpu.c rtc.c pit.c pic.c
|
||||
CONTIKI_SOURCEFILES += gdt.c helpers.S idt.c cpu.c rtc.c pit.c pic.c
|
||||
|
||||
### Compiler definitions
|
||||
CC = gcc
|
||||
|
|
188
cpu/x86/mtarch.c
188
cpu/x86/mtarch.c
|
@ -1,188 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sys/mt.h"
|
||||
|
||||
#ifndef __WORDSIZE
|
||||
#define __WORDSIZE 32
|
||||
#endif /* __WORDSIZE */
|
||||
|
||||
#ifndef ON_64BIT_ARCH
|
||||
#if __WORDSIZE == 64
|
||||
#define ON_64BIT_ARCH 1
|
||||
#else /* ON_64BIT_ARCH */
|
||||
#define ON_64BIT_ARCH 0
|
||||
#endif /* __WORDSIZE == 64 */
|
||||
#endif /* ON_64BIT_ARCH */
|
||||
|
||||
struct frame {
|
||||
unsigned long flags;
|
||||
#if ON_64BIT_ARCH
|
||||
unsigned long rbp;
|
||||
unsigned long rdi;
|
||||
unsigned long rsi;
|
||||
unsigned long rdx;
|
||||
unsigned long rcx;
|
||||
unsigned long rbx;
|
||||
unsigned long rax;
|
||||
#else /* ON_64BIT_ARCH */
|
||||
unsigned long ebp;
|
||||
unsigned long edi;
|
||||
unsigned long esi;
|
||||
unsigned long edx;
|
||||
unsigned long ecx;
|
||||
unsigned long ebx;
|
||||
unsigned long eax;
|
||||
#endif /* ON_64BIT_ARCH */
|
||||
unsigned long retaddr;
|
||||
unsigned long retaddr2;
|
||||
unsigned long data;
|
||||
};
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_init(void)
|
||||
{
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_start(struct mtarch_thread *t,
|
||||
void (*function)(void *), void *data)
|
||||
{
|
||||
struct frame *f = (struct frame *)&t->stack[MTARCH_STACKSIZE - sizeof(struct frame)/sizeof(unsigned long)];
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MTARCH_STACKSIZE; ++i) {
|
||||
t->stack[i] = i;
|
||||
}
|
||||
|
||||
memset(f, 0, sizeof(struct frame));
|
||||
f->retaddr = (unsigned long)function;
|
||||
f->data = (unsigned long)data;
|
||||
t->sp = (unsigned long)&f->flags;
|
||||
#if ON_64BIT_ARCH
|
||||
f->rbp = (unsigned long)&f->rax;
|
||||
#else /* ON_64BIT_ARCH */
|
||||
f->ebp = (unsigned long)&f->eax;
|
||||
#endif /* ON_64BIT_ARCH */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static struct mtarch_thread *running_thread;
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
sw(void)
|
||||
{
|
||||
/* Store registers */
|
||||
#if ON_64BIT_ARCH
|
||||
__asm__ (
|
||||
"pushq %rax\n\t"
|
||||
"pushq %rbx\n\t"
|
||||
"pushq %rcx\n\t"
|
||||
"pushq %rdx\n\t"
|
||||
"pushq %rsi\n\t"
|
||||
"pushq %rdi\n\t"
|
||||
"pushq %rbp\n\t"
|
||||
"pushq %rbp\n\t");
|
||||
#else /* ON_64BIT_ARCH */
|
||||
__asm__ (
|
||||
"pushl %eax\n\t"
|
||||
"pushl %ebx\n\t"
|
||||
"pushl %ecx\n\t"
|
||||
"pushl %edx\n\t"
|
||||
"pushl %esi\n\t"
|
||||
"pushl %edi\n\t"
|
||||
"pushl %ebp\n\t"
|
||||
"pushl %ebp\n\t");
|
||||
#endif /* ON_64BIT_ARCH */
|
||||
|
||||
/* Switch stack pointer */
|
||||
#if ON_64BIT_ARCH
|
||||
__asm__ ("movq %0, %%rax\n\t" : : "m" (running_thread));
|
||||
__asm__ (
|
||||
"movq (%rax), %rbx\n\t"
|
||||
"movq %rsp, (%rax)\n\t"
|
||||
"movq %rbx, %rsp\n\t"
|
||||
);
|
||||
#else /* ON_64BIT_ARCH */
|
||||
__asm__ ("movl %0, %%eax\n\t" : : "m" (running_thread));
|
||||
__asm__ (
|
||||
"movl (%eax), %ebx\n\t"
|
||||
"movl %esp, (%eax)\n\t"
|
||||
"movl %ebx, %esp\n\t"
|
||||
);
|
||||
#endif /* ON_64BIT_ARCH */
|
||||
|
||||
/* Restore previous registers */
|
||||
#if ON_64BIT_ARCH
|
||||
__asm__ (
|
||||
"popq %rbp\n\t"
|
||||
"popq %rbp\n\t"
|
||||
"popq %rdi\n\t"
|
||||
"popq %rsi\n\t"
|
||||
"popq %rdx\n\t"
|
||||
"popq %rcx\n\t"
|
||||
"popq %rbx\n\t"
|
||||
"popq %rax\n\t"
|
||||
|
||||
"leave\n\t"
|
||||
"ret\n\t"
|
||||
);
|
||||
#else /* ON_64BIT_ARCH */
|
||||
__asm__ (
|
||||
"popl %ebp\n\t"
|
||||
"popl %ebp\n\t"
|
||||
"popl %edi\n\t"
|
||||
"popl %esi\n\t"
|
||||
"popl %edx\n\t"
|
||||
"popl %ecx\n\t"
|
||||
"popl %ebx\n\t"
|
||||
"popl %eax\n\t"
|
||||
|
||||
"leave\n\t"
|
||||
"ret\n\t"
|
||||
);
|
||||
#endif /* ON_64BIT_ARCH */
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_exec(struct mtarch_thread *t)
|
||||
{
|
||||
running_thread = t;
|
||||
sw();
|
||||
running_thread = NULL;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_remove(void)
|
||||
{
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_yield(void)
|
||||
{
|
||||
sw();
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_pstop(void)
|
||||
{
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_pstart(void)
|
||||
{
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int
|
||||
mtarch_stack_usage(struct mt_thread *t)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < MTARCH_STACKSIZE; ++i) {
|
||||
if(t->thread.stack[i] != i) {
|
||||
return MTARCH_STACKSIZE - i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. 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.
|
||||
*
|
||||
*/
|
||||
#ifndef MTARCH_H_
|
||||
#define MTARCH_H_
|
||||
|
||||
#ifndef MTARCH_STACKSIZE
|
||||
#define MTARCH_STACKSIZE 1024
|
||||
#endif /* MTARCH_STACKSIZE */
|
||||
|
||||
struct mtarch_thread {
|
||||
/* Note: stack must be aligned on 4-byte boundary. */
|
||||
unsigned long stack[MTARCH_STACKSIZE];
|
||||
unsigned long sp;
|
||||
};
|
||||
|
||||
struct mt_thread;
|
||||
|
||||
int mtarch_stack_usage(struct mt_thread *t);
|
||||
|
||||
#endif /* MTARCH_H_ */
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
LIBC=$(CONTIKI)/platform/galileo/bsp/libc/i586-elf
|
||||
LIBGCC_PATH = /usr/lib/gcc/$(shell gcc -dumpmachine)/$(shell gcc -dumpversion)
|
||||
|
||||
CONTIKI_TARGET_DIRS = .
|
||||
CONTIKI_TARGET_DIRS = . core/sys/
|
||||
CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}
|
||||
CONTIKI_SOURCEFILES += contiki-main.c newlib-syscalls.c loader.S clock.c rtimer-arch.c
|
||||
|
||||
|
|
37
platform/galileo/core/sys/mtarch.h
Normal file
37
platform/galileo/core/sys/mtarch.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2015, Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``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
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef MTARCH_H_
|
||||
#define MTARCH_H_
|
||||
|
||||
struct mtarch_thread {
|
||||
};
|
||||
|
||||
#endif /* MTARCH_H_ */
|
Loading…
Reference in a new issue