Changed SMP code

This commit is contained in:
Alex
2022-10-20 05:04:15 +03:00
parent 7f47b2a3a4
commit fa92676d9f
7 changed files with 39 additions and 61 deletions

View File

@ -35,6 +35,7 @@ extern uint64_t _kernel_text_end, _kernel_data_end, _kernel_rodata_end;
#define TO_GPB(d) (d / 1024 / 1024 / 1024 / 1024 / 1024 / 1024 / 1024 / 1024 / 1024 / 1024)
#define PAGE_SIZE 0x1000
#define STACK_SIZE 0x10000
// to pages
#define TO_PAGES(d) (d / PAGE_SIZE + 1)

View File

@ -5,35 +5,40 @@
/** @brief Maximum supported number of CPU cores by the kernel */
#define MAX_CPU 256
#define CPU_DATA_CHECKSUM 0xC0FFEE
struct CPUArchData
{
#if defined(__amd64__)
int stub;
/* TODO */
#elif defined(__i386__)
#elif defined(__aarch64__)
#endif
};
struct CPUData
{
/**
* @brief CPU ID.
*/
uint64_t ID;
/**
* @brief Local CPU error code.
*/
/** @brief Used by syscall handler */
uint8_t *SystemCallStack; /* gs+0x0 */
/** @brief Used by syscall handler */
uint64_t TempStack; /* gs+0x8 */
/** @brief Used by CPU */
uint64_t Stack;
/** @brief CPU ID. */
long ID;
/** @brief Local CPU error code. */
long ErrorCode;
/**
* @brief Is CPU online?
*/
/** @brief Is CPU online? */
bool IsActive;
/**
* @brief Architecture-specific CPU data.
*/
void *Data;
/**
* @brief Checksum. Used to verify the integrity of the data. Must be equal to CPU_DATA_CHECKSUM (0xC0FFEE).
*/
/** @brief Architecture-specific CPU data. */
CPUArchData *Data;
/** @brief Checksum. Used to verify the integrity of the data. Must be equal to CPU_DATA_CHECKSUM (0xC0FFEE). */
int Checksum;
} __attribute__((packed));
CPUData *GetCurrentCPU();
CPUData *GetCPU(uint64_t ID);
CPUData *GetCPU(long ID);
namespace SMP
{