CS 630: Advanced Microcomputer Programming (Fall 2006)
Lecture: Tuesday-Thursday 7:30pm-9:15pm (235 Harney Science Center)
Instructor:
Allan Cruse
Email:
cruse@usfca.edu
Phone: (415) 422-6562
Office: 212 Harney Science Center
Office Hours: (see my homepage)
Synopsis:
This course explores fundamental capabilities of Intel's Pentium
microprocessor, regarded as a "bare machine" for which the basic
software components of an operating system are to be constructed
in a context of standard PC-BIOS firmware and peripheral devices
(a.k.a the 'Pre-boot eXecution Environment').
Topics appropriate to this goal include:
- crafting a bootstrap loader
- identifying the processor model and stepping
- segmented real-mode memory-addressing
- peripheral device detection and initialization
- the CMOS memory and real-time clock
- keyboard, monitor, and interval-timers
- the programmable interrupt controllers
- building protected-mode segment-descriptors
- entering and leaving 16-bit or 32-bit protected-mode
- creating exception-handlers and interrupt-descriptors
- building page-tables for virtual-memory support
- privilege-level transitions and multitasking mechanisms
- emulation of the legacy 8086 execution environment
- support for debugging and performance monitoring
- initialization and communication among multiple CPUs
- the memory controller hub and system management mode
Throughout the course small software-component prototypes will be
written using the GNU/Linux program development tools (including
assemblers and C/C++ compilers). The course is open to graduate
students in computer science (and to qualified undergraduates or
non-degree students when the Instructor has granted permission).
Students are assumed to be familiar with Linux or UNIX, and with
programming in C/C++ and to be acquainted with the Intel Pentium
processor's registers, instruction-set, and assembly language.
Learning Outcomes:
- You will broaden your knowledge of standard 32-bit Intel Architectures.
- You will increase your proficiency with using C and assembler language.
- You will become aware of the Intel processors' seldom-used capabilities.
- You will know how to access service-functions provided in BIOS firmware.
- You will gain practical experience in programming peripheral I/O devices.
- You will acquire the background for understanding next-generation CPUs.
- You will lay a foundation for pursuing some additional career options.
Class meetings will be held in the
Michael D. Kudlick computer classroom
(Room 235, Harney Science Center) which affords convenient opportunities
for combining formal instruction with "hands-on" programming exercises.
This facility, a gift of USF alumnus
Alfred S. Chuang ('82), opened in Fall 2002.
Textbook:
Resources
Readings
- Week 1: Part One (Chapters 1-3) in textbook by Shanley
- Week 2: Part Two (Chapters 4-5) in textbook by Shanley
- Week 3: Part Three (Chapters 6-7) in textbook by Shanley
- Week 4: Part Three (Chapters 8-9) in textbook by Shanley
- Week 5: Part Three (Chapters 10-11) in textbook by Shanley
- Week 6: Part Three (Chapter 12) in textbook by Shanley.
- Week 7: Data Sheet for 8259A Programmable Interrupt Controller.
- Week 8: Official Documentation for ELF files (Chapter One).
- Week 9: Official Documentation for ELF files (Chapters 2-3).
- Week 10: Part Three (Chapters 13-14) in textbook by Shanley.-
- Week 11: Part Three (Chapter 15) in textbook by Shanley.
- Week 12: Intel Multiprocessor Specification version 1.4
- Weeks 13-15: No new assignment (work on Project 2 and course review).
Systems Software
- Utility program: ljpages.cpp
(a tool that submits your program source to a laser printer)
- Utility program: dump.cpp
(a tool that displays the contents of any file in hex and ascii)
- Utility program: fileview.cpp
(a navigation tool for viewing the contents of binary files)
- Utility program: iopl3.cpp
(a tool by Alex Fedosov that lets user programs do direct I/O)
- Device-driver: 8086.c
needed for addressing I/O ports and accessing 8086 memory
- Utility program: mmake.cpp
(a tool for compiling Linux 2.6 kernel modules)
<-- revised 7/27/2006
- Support files: int86.h and
int86.cpp
(we link these with programs that call BIOS routines)
- Linker script: ldscript
allows the GNU linker 'ld' to produce a 'binary-format' executable
- Device-driver: dram.c
needed to allow reading from the workstation's physical memory
Handouts
0203-630-01: Course syllabus(.pdf-format)
lesson1.ppt (PowerPoint Slides)
Demo program: bootmsw.s
a 'boot-sector' program that display's the Pentium's Machine Status Word
lesson2.ppt (PowerPoint Slides)
Demo program: memsize.s
a boot-sector program to show the extent of real-mode memory (in KB)
Demo program: viewrbda.s
boot-sector program giving a dynamic look at the ROM-BIOS DATA-AREA
Demo program: viewivt.s
a boot-sector program that shows the Interrupt Vector Table's 256 entries
<-- revised 8/30/2006
lesson3.ppt (PowerPoint Slides)
Demo program: tickdemo.s
illustrating the basic elements of a (real-mode) Interrupt Service Routine
lesson4.ppt (PowerPoint Slides)
Demo program: finalpte.s
reads the Master Boot Record and shows its final Partition-Table Entry
Demo program: greeting.s
for use when testing our programs that transfer code from disk to memory
lesson5.ppt (PowerPoint Slides)
Demo program: sysregs.s
a boot-sector program that shows the values in several 'system' registers
lesson6.ppt (PowerPoint Slides)
Demo program: pmhello.s
shows segment-register usage when entering and leaving protected-mode
Classroom tool: quikload.s
a 'boot-loader' that launches binary-executables from our disk-partition
lesson7.ppt (PowerPoint Slides)
Demo program: tryring1.s
to show how a processor 'privilege-level transition' may be accomplished
<-- modified on 09/15/2008
lesson8.ppt (PowerPoint Slides)
Demo program: twotasks.s
demonstrates the Pentium's ability to do 'context-switching' between tasks
lesson9.ppt (PowerPoint Slides)
Demo program: pmtimer.s
showing how you can handle the 'timer-tick' interrupts in protected-mode
lesson10.ppt (PowerPoint Slides)
Demo program: whycrash.s
uses a protected-mode fault-handler to show some system-crash diagnostics
lesson11.ppt (PowerPoint Slides)
Demo program: notready.s
uses the 'Segment-Not-Present' exception to simulate 'loading-on-demand'
lesson12.ppt (PowerPoint Slides)
<-- two extra slides added on 10/10/2006
Demo program: minikybd.s
illustrates basic steps in handling interrupts from the Keyboard Controller
lesson13.ppt (PowerPoint Slides)
Demo program: reporter.s
to illustrate the 'reprogramming' of the two 8259A Interrupt Controllers
<-- bug fix 10/14/2008
lesson14.ppt (PowerPoint Slides)
Demo program: arrows.s
illustrating "polled-mode" keyboard programming and CRT cursor movements
lesson15.ppt (PowerPoint Slides)
Demo program: manydots.s
(a Linux application that we want to execute without using Linux)
Demo printout: manydots.opd
(dump of the 'manydots.o' object-file, showing its ELF sections)
CS630 utility: loadmap.cpp
(a tool for studying the sections in a relocatable ELF object-file)
Demo program: try32bit.s
(it executes the 32-bit code in a linkable ELF-file named 'hello.o')
<-- bug-fixes on 10/18/2006
Demo program: hello.s
(source-text for the Linux program used with our 'try32bit.s' demo)
lesson16.ppt (PowerPoint Slides)
Demo program: timeoday.s
implements the steps that convert 'tick_count' into time-of-day
lesson17.ppt (PowerPoint Slides)
Demo program: trydebug.s
(illustrates single-stepping through code in an ELF application)
lesson18.ppt (PowerPoint Slides)
Demo program: ideload1.s
a replacement for our 'quikload.s' boot-loader that uses Programmed I/O
Demo program: ideload2.s
a replacement for our 'quikload.s' boot-loader that uses Bus Master DMA
Include file: platform.inc
for the platform-specific parameters needed by 'ideload1.s' and 'ideload2.s'
lesson19.ppt (PowerPoint Slides)
Demo program: mixcalls.s
illustrates long calls and returns between 16-bit and 32-bit code-segments
Test program: queryA20.s
this program checks to see if the A20 address-line is enabled at boot-time
Demo program: alphabet.s
(The source-text for a Linux application to be adapted for use in Project 2)
CS630 utility: elfinfo.cpp
(a tool for studying the sections in a relocatable or an executable ELF file)
Exercise solution: elfexec.s
we rewrote 'try32bit.s' so it runs our ELF executable file named 'hello'
lesson20.ppt (PowerPoint Slides)
Demo program: trypages.s
it builds and activates a page-directory with just one page-table entry
Demo program: showCR4.s
it shows one possible way to answer Question V on Midterm Exam II
lesson21.ppt (PowerPoint Slides)
Demo program: tryvm86.s
it executes a "real-mode" procedure in virtual-8086 emulation mode
Demo program: emulate.s
it executes ROM-BIOS routines in virtual-8086 mode, but with IOPL<3
lesson22.ppt (PowerPoint Slides)
Demo program: rtcdemo.s
to illustrate programming of the Real-Time Clock's 'update' interrupt
lesson23.ppt (PowerPoint Slides)
Demo program: cpuid.cpp
illustrates use of the 'cpuid' instruction (to detect cpu's capabilities)
Demo program: apictick.s
to demonstrate programming of the cpu's Local-APIC timer interrupt
Demo program: smpinfo.cpp
shows the MP Floating Pointer Structure and Base Configuration entries
<-- modified on 12/26/2006
lesson24.ppt (PowerPoint Slides)
Demo program: cpuslice.s
uses APIC's Timer to implement processor timesharing among several tasks
Demo program: smphello.s
illustrating the MP protocol for awakening any auxilliary processors
lesson25.ppt (PowerPoint Slides)
Utility program: pciprobe.cpp
showing how software can identify a system's PCI device-functions
lesson26.ppt (PowerPoint Slides)
Demo program: activity.s
it produces a dynamic display of all interrupt-activity at boot-time
Demo program: activity.cpp
shows a similar display of interrupt-activity under the Linux OS
Kernel module: activity.c
this driver is needed for running the Linux 'activity.cpp' application
lesson27.ppt (PowerPoint Slides)
Demo program: try64bit.s
offers an illustration of the role played by some Model-Specific Registers
Utility program: newasapp.cpp
it quickly creates the 'boilerplate' text for a new protected-mode demo
Demo program: smpwatch.cpp
shows a real-time display of dual-CPU interrupt-activity under Linux
Kernel module: smpwatch.c
this driver is required when running our Linux 'smpwatch.cpp' application
Announcements
- Midterm Exam 1: Tuesday, October 3
- Project 1: Due by Tuesday, October 31, 7:30pm
- Midterm Exam 2: Tuesday, November 7
- Project 2: Due by Tuesday, November 28, 7:30pm
- FINAL EXAMINATION: Tuesday, December 12, 7:30pm
Last updated on 10/14/2008