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

Do you know? #11

Open
eprparadocs opened this issue Feb 27, 2025 · 0 comments
Open

Do you know? #11

eprparadocs opened this issue Feb 27, 2025 · 0 comments

Comments

@eprparadocs
Copy link

eprparadocs commented Feb 27, 2025

Your startup isn't quite correct, so I thought I would give you some idea of what you need to know.

First, you should have something like this function in the initial code.

              int getLogicalProcessorCount() {
                  unsigned int eax, ebx, ecx, edx;
              
                  // Check CPUID support (simplified)
                  __asm__ volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(0));
              
                  // Get extended CPUID support
                  __asm__ volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(0x80000000));
              
                  if (eax >= 0x80000008) {
                      // Get logical processor count
                      __asm__ volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(0x80000008));
                      return (ebx & 0xFF); // Extract logical core count from lower 8 bits.
                  }
              
                  return 1; // Default to 1 processor if CPUID fails.
              }

It's necessary to set up each of the getLogicalProcessorCount() processors. Each of them has an LAPIC, paging, etc,. You can steer certain interrupts to certain processors. Of course I am assuming you will want to run this on real hardware. If this is QEMU only application, just set the processor count to 1 and you won't need to deal with things.

You could do something like run the above function and if the count comes back greater than 1, just print out an error message and halt. Otherwise things get pretty complicated and you will have to know a lot about the Amd64/x86_64.

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

No branches or pull requests

1 participant