List of questions: - retrotruestory/M1DEV GitHub Wiki
Can you explain the specific role and functionality of the supervisor mode in the Magic-1 computer?
When you think about multiple processes running on a single computer, you want to have the ability to provide separation between them. One process should not be able to blindly interfere with another process. Magic-1 instructions that manipulate system-wide resources, such as WCPTE (Write Code Page Table Entry), can only be executed in supervisor mode. Supervisor mode, also often called kernel mode, is only used by the operating system. Normal processes run in user mode.
How does the Magic-1 handle the transition from supervisor mode to user mode, and under what circumstances does this transition occur?
The transition from user to supervisor mode only happens in 2 situations: system reset and when the system accepts an interrupt or trap. On power-on reset, we must start in supervisor mode - otherwise we'd never be able to initialize the system. The transition from supervisor mode to user mode happens when the Mode bit of the MSW is written via either "RETI" or "COPY MSW,A".
What are the key differences between supervisor mode and user mode in terms of privileges and access to system resources?
Take a look at the microcode. Instructions with the code "PRIV(1)" may only be executed in supervisor mode. In general, they deal with managing the page table, enabling/disabling interrupts, enabling/disabling paging and copying data between kernel and user pages.
Can you provide details on the interrupt handling mechanism in Magic-1, particularly how it operates when interrupts are disabled in supervisor mode?
There are differences between traps and interrupts. Traps cannot be disabled, and will be recognized by the system immediately (even in the middle of executing an instruction). Interrupts can be disabled, and will only be acknowledged between instruction executions. When interrupts are disabled, they are still recorded via the flip-flops on the traps/interrupts schematics sheet.
When a trap or interrupts is acknowledged, the machine state is saved to memory pointed to by the SSP (system or kernel stack pointer), the system enters supervisor mode and then control is vectored to a trap/interrupt handler based on its priority number. Look at workspace/M1Dev/root/usr/src/kernel/mpmagic.s. That's where the interrupt vectors live.
Another difference in user/supervisor mode is that when operating in supervisor mode the system uses SSP (the system stack pointer) instead of regular SP.
How is paging managed in the Magic-1, and what are the implications of paging being disabled in supervisor mode upon reset or power-up?
Paging must be disabled on power up so we can initialize the page table before turning it on. When paging is disabled, the system can only see the first 64K bytes of device memory. Unlike when paging is on, buth code and data accesses refer to the same physical memory. The power-on process is somewhat complicated, but I think I've documented it in the bootloader code.
What security measures are in place to ensure the integrity and stability of the system when operating in supervisor mode?
The primary security measure is that you can only execute the special instructions that modify the page table and interrupt state while in supervisor mode.
Can you describe the typical use cases or scenarios where the Magic-1 operates predominantly in supervisor mode?
In Minix, operating system functions such as reading/writing to disk, are managed via "system calls". System calls are implemented using the special instruction SYSCALL which causes a trap. The SYSCALL trap causes the system to enter supervisor mode, where the operating system can carry out the request.
Are there any specific instructions or instructions sets that are exclusive to supervisor mode in Magic-1, and if so, what are they?
See instructions that use "PRIV(1)" on the microcode page.
How does the Magic-1's supervisor mode compare to similar modes in other computer architectures you have worked on?
Similar, though simplified. Most modern systems have multiple levels of supervisor mode.
What are the challenges and considerations involved in developing a virtual machine that can accurately interpret and run the Magic-1's supervisor mode instructions on another architecture?
You don't necessarily need to use the real Magic-1 supervisor mode to create a virtual machine that interprets a different architecture. This could be simulated in user-mode software.
Bill