Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

179 initialize user mode #181

Merged
merged 18 commits into from
Oct 23, 2023
Merged

179 initialize user mode #181

merged 18 commits into from
Oct 23, 2023

Conversation

dreamos82
Copy link
Owner

No description provided.

@dreamos82 dreamos82 marked this pull request as draft September 25, 2023 15:27
@dreamos82 dreamos82 marked this pull request as ready for review October 18, 2023 22:25
loglinef(Verbose, "(%s) Initializing tss", __FUNCTION__);

// These fields are reserved and must be set to 0
kernel_tss.reserved0 = 0x00;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that this is all explicit, but it'd be more efficient to use memset() to zero the whole tss and then set the fields you want afterwards.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i totally agree, but i haven't implemented memset yet XD

// LIMIT 16:19 0 DPL: 0 P: 1 G:0
gdt64[TSS_ENTRY_LOW] = 0x00;
gdt64[TSS_ENTRY_HIGH] = 0x00;
gdt64[TSS_ENTRY_LOW] = ((((uint64_t) &kernel_tss>>24) & 0xFF)<<56) /*bits 56:63*/ | ((uint64_t) (0 & 0xFF) << 48) /* bits 48:55 */ | ((uint64_t)0x89 << 40) /* bits 40:47*/| ((((uint64_t) &kernel_tss) & 0xFFFFFF) << 16) /* bits 15:39 */ | (uint64_t) 0x70 /* Base */;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like lisp! hahaha
It might be easier to understand if you break this down into a few smaller steps (i.e. local variables) and then assemble those.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but then shouldn't be better to create a struct with bitfields?
If i start to create local variable is more or less the same aestethically.
Am i wrong?

Btw yeah probably at least using variables, shoul make it more readable!

@DeanoBurrito DeanoBurrito merged commit 6664d72 into master Oct 23, 2023
3 checks passed
@DeanoBurrito DeanoBurrito deleted the 179_initialize_user_mode branch October 23, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants