Skip to content
Snippets Groups Projects
Commit 054c8801 authored by Armin Luntzer's avatar Armin Luntzer
Browse files

consolidate gr740 merge

parent 2eb8971b
No related branches found
No related tags found
No related merge requests found
# gcc (7.2.0)
#
#ARCH_CFLAGS = -mcpu=leon3 -mfix-gr712rc
ARCH_CFLAGS = -mcpu=leon3 -mhard-float
# gcc (4.x)
#ARCH_CFLAGS = -mcpu=v8 -mfix-gr712rc
# clang
#ARCH_CFLAGS = -mcpu=gr712rc
# gcc (7.2.0)
ifeq ($(CONFIG_LEON4),y)
KBUILD_CFLAGS += -m32 -mcpu=leon3 -mhard-float
endif
ifeq ($(CONFIG_LEON3),y)
ARCH_CFLAGS = -mcpu=leon3 -mfix-gr712rc
endif
......@@ -20,9 +20,11 @@
* blocks
*/
#ifdef CONFIG_LEON4
#define LEON3_GPTIMERS 5
#else
#define LEON3_GPTIMERS 4
#endif
#ifdef CONFIG_LEON4
#define GPTIMER_0_IRQ 1
......
......@@ -507,7 +507,7 @@ void leon_disable_irq(unsigned int irq, int cpu)
void leon_force_irq(unsigned int irq, int cpu)
{
#ifdef CONFIG_LEON3
#if defined(CONFIG_LEON3) || defined(CONFIG_LEON4)
if (cpu >= 0) {
iowrite32be((1 << irq), &leon_irqctrl_regs->irq_mpforce[cpu]);
return;
......
......@@ -77,7 +77,9 @@ static void mem_init(void)
#ifdef CONFIG_MPPB
sp_banks[0].base_addr = 0x40000000;
sp_banks[0].num_bytes = 0x10000000;
#elif CONFIG_LEON4
#endif
#ifdef CONFIG_LEON4
sp_banks[0].base_addr = 0x00000000;
sp_banks[0].num_bytes = 0x10000000;
#else /* e.g. GR712 eval */
......@@ -95,7 +97,7 @@ static void mem_init(void)
}
int cpu_ready[4];
int cpu_ready[CONFIG_SMP_CPUS_MAX];
#include <asm/io.h>
......@@ -103,34 +105,28 @@ int cpu_ready[4];
void cpu_wake(uint32_t cpu_id)
{
#ifdef CONFIG_LEON3
iowrite32be(cpu_id, (uint32_t *) 0x80000210);
iowrite32be(1 << cpu_id, (uint32_t *) 0x80000210);
#endif
#ifdef CONFIG_LEON4
iowrite32be(cpu_id, (uint32_t *) 0xFF904010);
iowrite32be(1 << cpu_id, (uint32_t *) 0xFF904010);
#endif
}
/** XXX crappy */
static void boot_cpus(void)
{
printk("booting cpu1\n");
cpu_wake(0x2); /*cpu 1 */
while (!ioread32be(&cpu_ready[1]));
printk("cpu1 booted\n");
int i;
printk("booting cpu2\n");
cpu_wake(0x4); /*cpu 2 */
while (!ioread32be(&cpu_ready[2]));
printk("cpu2 booted\n");
for (i = 1; i < CONFIG_SMP_CPUS_MAX; i++) {
printk("booting cpu %d\n", i);
cpu_wake(i);
printk("booting cpu3\n");
cpu_wake(0x8); /*cpu 3 */
while (!ioread32be(&cpu_ready[i]));
printk("cpu %d booted\n", i);
while (!ioread32be(&cpu_ready[3]));
printk("cpu3 booted\n");
}
}
......@@ -140,20 +136,23 @@ extern struct task_struct *kernel[];
void smp_cpu_entry(void)
{
reserve_kernel_stack();
BUG_ON(stack_migrate(NULL, _kernel_stack_top));
reserve_kernel_stack();
BUG_ON(stack_migrate(NULL, _kernel_stack_top));
printk("hi i'm cpu %d\n", leon3_cpuid());
arch_local_irq_enable();
BUG_ON(!leon3_cpuid());
/* signal ready */
iowrite32be(0x1, &cpu_ready[leon3_cpuid()]);
printk("hi i'm cpu %d\n", leon3_cpuid());
BUG_ON(!leon3_cpuid());
/* signal ready */
iowrite32be(0x1, &cpu_ready[leon3_cpuid()]);
while (ioread32be(&cpu_ready[leon3_cpuid()]) != 0x2);
BUG_ON(clockevents_offer_device()); /* XXX CLOCK */
kthread_init_main();
iowrite32be(0x3, &cpu_ready[leon3_cpuid()]);
iowrite32be(0x3, &cpu_ready[leon3_cpuid()]);
while (ioread32be(&cpu_ready[leon3_cpuid()]) != 0x4);
sched_enable();
......
......@@ -14,20 +14,25 @@
#include <asm/leon.h>
#endif
#ifdef CONFIG_LEON4
#include <asm/leon.h>
#endif
int smp_cpu_id(void)
{
#ifdef CONFIG_LEON3
#if defined(CONFIG_LEON4) || defined(CONFIG_LEON3)
return leon3_cpuid();
#else /* !CONFIG_LEON3 */
#endif
/* everything else */
return 0;
#endif /* CONFIG_LEON3 */
}
void smp_send_reschedule(int cpu)
{
#ifdef CONFIG_LEON3
#if defined(CONFIG_LEON4) || defined(CONFIG_LEON3)
/* trigger reschedule via forced IRQMP extended interrupt */
/* TODO sanity check for cpu id */
leon_force_irq(LEON3_IPIRQ, cpu);
......@@ -37,11 +42,12 @@ void smp_send_reschedule(int cpu)
void smp_init(void)
{
#ifdef CONFIG_LEON3
#if defined(CONFIG_LEON4) || defined(CONFIG_LEON3)
int i;
/* XXX need number of CPUs here */
leon_enable_irq(LEON3_IPIRQ, 0);
leon_enable_irq(LEON3_IPIRQ, 1);
for (i = 0; i < CONFIG_SMP_CPUS_MAX; i++)
leon_enable_irq(LEON3_IPIRQ, i);
#endif /* CONFIG_LEON3 */
}
......@@ -108,7 +108,7 @@ int task(void *p)
printk("IRQ total: %s timer1: %s timer2: %s, %d %d\n",
buf1, buf2, buf3, ioread32be(&xp), xd);
// sched_yield();
sched_yield();
}
return 0;
......@@ -117,12 +117,13 @@ int task(void *p)
/** XXX dummy **/
extern int cpu_ready[4];
extern int cpu_ready[CONFIG_SMP_CPUS_MAX];
/**
* @brief kernel main functionputchar( *((char *) data) );
*/
int kernel_main(void)
{
int i;
struct task_struct *t;
struct sched_attr attr;
......@@ -183,17 +184,16 @@ int kernel_main(void)
kthread_init_main();
/* wait for cpus */
cpu_ready[1] = 2;
while (ioread32be(&cpu_ready[1]) != 0x3);
iowrite32be(0x4, &cpu_ready[1]);
cpu_ready[2] = 2;
while (ioread32be(&cpu_ready[2]) != 0x3);
iowrite32be(0x4, &cpu_ready[2]);
for (i = 1; i < CONFIG_SMP_CPUS_MAX; i++) {
//printk("waiting for cpu %d, flag at %d\n", i, cpu_ready[i]);
cpu_ready[i] = 2;
while (ioread32be(&cpu_ready[i]) != 0x3);
iowrite32be(0x4, &cpu_ready[i]);
}
cpu_ready[3] = 2;
while (ioread32be(&cpu_ready[3]) != 0x3);
iowrite32be(0x4, &cpu_ready[3]);
printk(MSG "Boot complete\n");
......@@ -210,41 +210,44 @@ int kernel_main(void)
} else {
printk("Got an error in kthread_create!");
}
printk("%s runs on CPU %d\n", t->name, t->on_cpu);
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "task1");
if (!IS_ERR(t)) {
sched_get_attr(t, &attr);
attr.policy = SCHED_EDF;
attr.period = us_to_ktime(140);
attr.deadline_rel = us_to_ktime(115);
attr.wcet = us_to_ktime(90);
attr.period = us_to_ktime(300);
attr.deadline_rel = us_to_ktime(200);
attr.wcet = us_to_ktime(100);
sched_set_attr(t, &attr);
if (kthread_wake_up(t) < 0)
printk("---- %s NOT SCHEDUL-ABLE---\n", t->name);
} else {
printk("Got an error in kthread_create!");
}
printk("%s runs on CPU %d\n", t->name, t->on_cpu);
t = kthread_create(task2, NULL, KTHREAD_CPU_AFFINITY_NONE, "task2");
if (!IS_ERR(t)) {
sched_get_attr(t, &attr);
attr.policy = SCHED_EDF;
attr.period = us_to_ktime(140);
attr.deadline_rel = us_to_ktime(115);
attr.wcet = us_to_ktime(90);
attr.period = us_to_ktime(300);
attr.deadline_rel = us_to_ktime(200);
attr.wcet = us_to_ktime(100);
sched_set_attr(t, &attr);
if (kthread_wake_up(t) < 0)
printk("---- %s NOT SCHEDUL-ABLE---\n", t->name);
} else {
printk("Got an error in kthread_create!");
}
printk("%s runs on CPU %d\n", t->name, t->on_cpu);
while(1)
cpu_relax();
/* never reached */
BUG();
......
......@@ -23,7 +23,7 @@
static LIST_HEAD(kernel_schedulers);
static bool sched_enabled[2] = {false, false};
static bool sched_enabled[CONFIG_SMP_CPUS_MAX];
/* XXX: per-cpu... */
......
......@@ -36,7 +36,7 @@ static struct {
struct clock_event_device *dev;
} tick_device[2];
} tick_device[CONFIG_SMP_CPUS_MAX];
static void tick_calibrate_handler(struct clock_event_device *dev)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment