-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculates stack address for current AP from LAPIC id and use it call…
… smp_finish_initialization C code. Introcuded spin lock to synchronize smp_bits and printing messages from initializing APs. Clears identity mapping when SMP initialization is finished.
- Loading branch information
Showing
8 changed files
with
125 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*****************************************************************************/ | ||
/* File: lock.c */ | ||
/* */ | ||
/* Description: Source file for synchonization primitives. */ | ||
/* */ | ||
/* Author: Shoily O Rahman <[email protected]> */ | ||
/* */ | ||
/* Date: Oct 16, 2020 */ | ||
/* */ | ||
/*****************************************************************************/ | ||
|
||
#include "lock.h" | ||
|
||
void spinlock_lock(spin_lock *lock) { | ||
|
||
__asm__ __volatile__("movl $1, %%eax;" | ||
"1:;" | ||
"lock xchgl %0, %%eax;" | ||
"testl %%eax, %%eax;" | ||
"jne 1b;" | ||
: "=m" (lock->val) | ||
: "m" (lock->val) | ||
: "%eax", "%ebx", "cc", "memory" ); | ||
} | ||
|
||
void spinlock_unlock(spin_lock *lock) { | ||
|
||
__asm__ __volatile__("movl $0, %0;" | ||
: "=m" (lock->val) | ||
: | ||
: "cc", "memory" ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*****************************************************************************/ | ||
/* File: lock.h */ | ||
/* */ | ||
/* Description: Header file for synchonization primitives. */ | ||
/* */ | ||
/* Author: Shoily O Rahman <[email protected]> */ | ||
/* */ | ||
/* Date: Oct 16, 2020 */ | ||
/* */ | ||
/*****************************************************************************/ | ||
|
||
#ifndef _LOCK_H | ||
#define _LOCK_H | ||
|
||
typedef struct _spin_lock { | ||
int val; | ||
} spin_lock; | ||
|
||
#define INIT_SPIN_LOCK(spinlock) memset(spinlock, sizeof(spin_lock), 0) | ||
|
||
void spinlock_lock(spin_lock *lock); | ||
void spinlock_unlock(spin_lock *lock); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters