summaryrefslogtreecommitdiff
path: root/kernel/smp.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/smp.c')
-rw-r--r--kernel/smp.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/kernel/smp.c b/kernel/smp.c
index 8d122ee..f776c72 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -16,19 +16,22 @@ uint32_t c1,c2,c3;
volatile uint8_t proc;
uint32_t cpu_counter[SMP_MAX_PROC];
+extern
+
void smp_main()
{
- /// TODO
- /////// SYMMETRIC MULTIPROCESSING, APS get caought here, move it away ///
- // catch the APs (Application Processors)
-// if(mp==1)
- {
- uint32_t ebp=pmmngr_alloc_block()+4095;
- asm volatile("mov %0, %%ebp"::"r"(ebp));
- asm volatile("mov %ebp, %esp");
- asm volatile("jmp kernel_ap");
- }
+ // int_install();
+ // x86_int_enable();
+ switch_to_user_mode();
+
+ while(1);
+
+ uint32_t ebp=pmmngr_alloc_block()+4095;
+
+ asm volatile("mov %0, %%ebp"::"r"(ebp));
+ asm volatile("mov %ebp, %esp");
+ asm volatile("jmp kernel_ap");
proc=c1=c2=c3=0;
for(int i=0;i<SMP_MAX_PROC;i++)cpu_counter[i]=0;
@@ -58,22 +61,20 @@ void smp_log_procdata(smp_processors *procdata)
}
+
// this will start all our application processors!
-void smp_start_aps(smp_processors *pros,uint8_t *start_sel)
-{
+void smp_start_aps(smp_processors *pros,char *path)
+{
+ //lets copy the binary into mbr
+ fs_content(path,0x7000,0x100); // copy 0x100 bytes to 0x7000
- //lets copy the code to the bootsector !
-
- uint8_t *dest=0x7000;
- for(int i=0;i<0x100;i++)
- {
- dest[i]=start_sel[i];
+ // tell them where to enter (agreed adress at 0x8010)
+ uint32_t *entry=0x8010;
+ *entry=smp_main;
- }
-
//bsp (boot processor) enables its local apic
uint32_t *reg=pros->local_apic_address+FOOLOS_APIC_SPUR_INT;
- *reg=0xffffffff; // all bits 1 and interrupt 255
+// *reg=0xffffffff; // all bits 1 and interrupt 255
for(int i=0;i<pros->processors;i++)
{
@@ -90,12 +91,20 @@ void smp_start_aps(smp_processors *pros,uint8_t *start_sel)
*reg=(5<<8)|(1<<14); // 101 INIT
// do we really neet this?
+ // TODO!!
// todo: use some real sleep (not implemented yet :( )
//sleep(30);
// start proc 0x7 = 0x7000; etc..
*reg=(6<<8)|(1<<14)|0x7; // 110 SIPI
+
+ //bsp (boot processor) enables its local apic
+ uint32_t *reg=pros->local_apic_address+FOOLOS_APIC_SPUR_INT;
+ // *reg=0xffffffff; // all bits 1 and interrupt 255
+
+
}
}
+