Bootable Programs - dforeman.cs.bingh

Download Report

Transcript Bootable Programs - dforeman.cs.bingh

Bootable Programs
Building an O/S
Basic Requirements of any O/S
•
•
•
•
•
Respond to interrupts (all kinds)
Preserve user environment
Protect users and self from corruption
Handle I/O errors
Handle user errors
Responding to ANY interrupt
• Hardware loads a pre-defined state vector
– Context switch occurs
– NSI is inside kernel at primary interrupt handler
• Primary handler determines type of interrupt
–
–
–
–
I/O completion
Service call
Program error
Paging/addressing exception
• Save user’s environment (stack, registers) in
process’s PCB or thread’s TCB
• Branch to detail interrupt handler
Detail interrupt handler
• Take required action
– All instructions valid
– Must not cause another interrupt
• Therefore must not do I/O - one exception:
– Handling I/O errors may require I/O to device
– Interrupt for this 2ndary I/O must be deleted
• Must allow for all possible (and improbable) errors
• Return to common return point
Common return to user
• Determine next thread/process to run
– New user
– Interrupted user
• Locate PCB/TCB for selected user
• Prep state vector, could be:
– Old vector (in reserved RAM) from previously interrupted
program
– New vector data determined for a new program
• Save kernel’s registers in reserved storage
• Restore user’s registers & stack from PCB/TCB
• Load prepared state vector for user
• Context switch occurs
SOS
• A Small Operating System
• “built-in” user command-line shell
• Written in z/390 assembler language
– 32-bit mode
– Runs in a z/390 virtual machine
• You will
– Modify it to provide service call handling
– Install it as a bootable program
– Boot it
– Test it
SOS – bootable drive
• Virtual device at address 222
• Preformatted as a CMS disk
– Simplifies putting programs on the drive
– Reserved space for the bootable program (SOS)
– Boot loader (IBM supplied) installed by student
– Allows seeing disk content from CMS shell
SOS – original contents
• Device address discovery
– Operator’s terminal
– Boot drive
•
•
•
•
Locate volume TOC
Locates file directory
Displays content of directory in hexadecimal
Terminates
SOS - Lab 1
•
•
•
•
•
Copy the SOSSAMP file to your “a-disk”
Rename it to: SOS
Assemble it using HLASM
Prepare the bootable drive
Boot it
SOS – Lab 2
•
•
•
•
Add “shell” code to the single compile
Add state-vector loading to “activate” shell
Shell displays your prompt, waits for input
Shell issues SVC n in response to input
– 0<= n <= 7
– See lab assignment for details
• SOS gets control and performs service “n”
• SOS
– returns control to shell
– loads “terminate” state vector