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

consolidate gr740 merge

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