CS 630: Advanced Microcomputer Programming (Fall 2008)
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 Core-2 Quad
microprocessor, regarded as a "bare machine" for which some 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. PXE, the so called 'Pre-boot eXecution Environment').
Topics appropriate to this goal include:
- crafting a bootstrap loader
- identifying a processor's model and stepping
- segmented real-mode memory-addressing
- device detection and initialization
- the CMOS memory and real-time clock
- keyboard, monitor, and interval-timers
- the programmable interrupt controllers
- floating-point, mmx, and simd instructions
- building protected-mode segment-descriptors
- entering and leaving 16-bit/32-bit/64-bit protected-modes
- creating exception-handlers and interrupt-descriptors
- building page-tables for virtual-memory support
- processor mechanisms for multitasking and debugging
- emulation of the legacy 8086 execution environment
- initialization and communication among multiple CPUs
- system management mode and performance monitoring counters
- aims of the UEFI (Unified Extensible Firmware Interface) endeavor
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 and in x86 assembly language.
Learning Outcomes:
- You will broaden your knowledge of standard 32-bit Intel Architectures.
- You will become aware of the Intel processors' seldom-used capabilities.
- You will increase your proficiency with using C and assembler language.
- 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(s):
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: No new assignment (work on Project 2 and midterm review).
- Week 11: Intel Multiprocessor Specification version 1.4
- Week 12: Part Three (Chapters 13-14) in textbook by Shanley.-
- Week 13: Part Three (Chapter 15) in textbook by Shanley.
- Weeks 14-15: No new assignment (review for Final Examination).
Resources
- Official
Intel 64 and IA-32 Architecture Software Developer's Manuals
(online)
- Professor Ralf Brown's Interrupt List online at
http://www.ctyme.com/rbrown.htm
- BiosCentral's map of the PC's
ROM-BIOS Data Area (online)
- Online documentation:
PC Industry Specifications hosted by Phoenix Technologies, Inc.
- Online reference:
List of Hard Disk Partition Identifiers by Andries Brouwer
- Online industry document:
Intel Multiprocessor Specification (version 1.4)
(.pdf format)
- Online book-chapters:
Linux Device Drivers, Third Edition, (O'Reilly Media, Inc., 2005)
- The official GNU Assembler manual:
Using as (online)
-
Brennan's Guide to Inline Assembly
- Official Data Sheet for the
Intel 8259A Programmable Interrupt Controller
(.pdf file-format)
- Documentation for the Linux Executable and Linkable Format (ELF) files:
elf.pdf
- Official Data Sheet for the
Intel 82C54 Programmable Interval Timer
(.pdf file-format)
- Official datasheet for the
16550 Serial UART (.pdf format), National Semiconductor, Inc
- Online guide to
ANSI terminal escape-sequences
- Online article:
A20 - a pain from the past by Andries Brouwer
- Official Data Sheet for the
Intel I/O Controller Hub (ICH7) Family Datasheet
(.pdf file-format)
- Website for ATA Disk-Drive Interface
Draft ANSI Standards Documentation by INCITS Technical Committee T13
- De facto standard:
Programming Interface for Bus Master IDE Controller
(1994), by Brad Hosler (.pdf file-format)
- Industry document: Video Electronics Standards Association (VESA)
Video BIOS Extension: Core Functions Standard 3.0
vbe3.pdf
(1998)
by MonsterSoft, Inc.
-
Online tutorial:
Introduction to VESA Programming hosted by MonsterSoft, Inc.
- Online tutorial on the
Unified Extensible Firmware Interface(.pdf)
- Official Data Sheet for the
Intel 3000 and 3010 Chipset Memory Controller Hub (MCH) Datasheet
(.pdf)
Systems Software
- Linker script: ldscript
allows the GNU linker 'ld' to produce a 'binary-format' executable
- Utility program: ljpages.cpp
(a tool that submits your program source to a laser printer)
<-- modified on 11/02/2008
- 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)
- Device-driver: dram.c
(used to allow reading from a workstation's physical memory)
- Device-driver: vram.c
(used for accessing the workstation's graphics frame-buffer)
- Utility program: mmake.cpp
(a tool for compiling our own Linux 2.6 kernel modules)
- Development tool: newproc.cpp
builds the sketeton for an LKM that creates a '/proc' file
- Development tool: newasapp.cpp
builds the sketeton for a boot-time assembly application
Handouts
- 0203-630-01: Course syllabus (.PDF)
- lesson1.ppt (PowerPoint Slides)
- Demo program: welcome.s
a boot-sector replacement that uses some ROM-BIOS function-calls
- lesson2.ppt (PowerPoint Slides)
- Demo program: memsize.s
a boot-sector program showing the amount of memory in real-mode
- Demo program: viewrbda.s
this program offers a 'dynamic' view of the ROM-BIOS DATA-AREA
- lesson3.ppt (PowerPoint Slides)
- Demo program: tickdemo.s
illustrating basic elements of a (real-mode) Interrupt Service Routine
- lesson4.ppt (PowerPoint Slides)
- Demo program: cs630ipl.s
a 'boot-loader' that launches binary-executables from our disk-partition
- Demo program: ourfirst.s
an application that shows a message, to confirm our boot-loader worked
- lesson5.ppt (PowerPoint Slides)
- Demo program: pmhello.s
shows how to set up segment-descriptors, needed for 'protected-mode'
- lesson6.ppt (PowerPoint Slides)
- Demo program: tryring1.s
showing how a processor's privilege-level transitions are accomplished
- lesson7.ppt (PowerPoint Slides)
- Demo program: twotasks.s
shows context-switching and code-sharing among two program-threads
- lesson8.ppt (PowerPoint Slides)
- Demo program: pmtimer.s
shows how you could handle the 'timer-tick' interrupts in protected-mode
- lesson9.ppt (PowerPoint Slides)
- Demo program: whycrash.s
uses a protected-mode fault-handler to show some 'crash' diagnostics
- lesson10.ppt (PowerPoint Slides)
- Demo program: notready.s
uses the 'Segment-Not-Present' fault for a 'load-on-demand' simulation
- lesson11.ppt (PowerPoint Slides)
- Demo program: minikybd.s
illustrates the handling of interrupts from the PC's Keyboard Controller
- Demo program: haltdemo.s
explores effects of the 'hlt'-instruction in a new version of 'tickdemo.s'
- Exercise solution: kybdplus.s
showing one possible way to answer Question V on Midterm Exam I
- lesson12.ppt (PowerPoint Slides)
- Demo program: arrowpad.s
illustrates "polled-mode" programming and movement of CRT's cursor
- lesson13.ppt (PowerPoint Slides)
- Demo program: reporter.s
showing steps in reprogramming of the two 8259A Interrupt Controllers
<-- bug fixed on 09/17/2008
- Demo program: trymouse.s
uses ROM-BIOS services to enable interrupts for PS/2 mouse-events
- lesson14.ppt (PowerPoint Slides)
- Demo program: manydots.s
a Linux application, which we propose to execute without using Linux
- CS630 utility: loadmap.cpp
our own tool for studying the sections in a 'relocatable' Elf32 object-file
- Demo program: linuxapp.s
source-text for a Linux program we'll execute with our 'tryelf32.s' demo
- Demo program: tryelf32.s
it can execute the 32-bit code in the linkable ELF-file named 'linuxapp.o'
- lesson15.ppt (PowerPoint Slides)
- Demo program: wait10ms.s
illustrates programming of the 8254 Timer for a ten-milliseconds delay
- Demo program: timeoday.s
implements arithmetical steps that convert 'tick_count' into time-of-day
- lesson16.ppt (PowerPoint Slides)
- Demo program: usedebug.s
illustrates 'single-stepping' through the code in our 'linuxapp.o' demo
- Program listing: linuxapp.lst
shows instruction-addresses and opcode-mnemonics for 'linuxapp.o'
- lesson17.ppt (PowerPoint Slides)
- Kernel module: uart.c
a character-mode device-driver that supports the PC's 16550 serial-UART
- Utility program: kb2cable.cpp
transmits keyboard-input to another PC using its null-modem cable
- Demo program: remotedb.s
revises our 'usedebug.s' single-stepping demo to use serial-port input
- In-class exercise: addkbisr.s
uses UART for 'single-stepping' through a keyboard interrupt-handler
- lesson18.ppt (PowerPoint Slides)
- Demo program: xmitvram.s
it reimplements 'console redirection' in protected-mode (for 'anchor's)
- Debugging exercise: exambugs.s
for you to use when answering Question V on Midterm Exam II
- lesson19.ppt (PowerPoint Slides)
- Demo program: queryA20.s
for finding out whether the A20 address-line is 'disabled' at boot-time
- Demo program: usingbss.s
for seeing how the GNU linker handles unitialized data-section ('.bss')
- CS630 utility: elfinfo.cpp
for reporting the sections in a 'relocatable' or an 'executable' ELF_32 file
- Demo program: elfexec.s
simulates 'on-demand' loading and execution of an 'executable' ELF file
- lesson20.ppt (PowerPoint Slides)
- Demo program: vrampage.s
offers a simple example of how we can create and use a page-table
- Demo program: pgfaults.s
illustrates the CPU's page-fault error-codes for a few paging violations
- lesson21.ppt (PowerPoint Slides)
- Demo program: genuine.s
this Linux program executes the x86's (unprivileged) 'cpuid' instruction
- Utility program: cpuid.cpp
uses the processor's 'cpuid' instruction to report processor capabilities
- Utility program: mpinfo.cpp
shows the system-information stored in the 'MP Configuration Table'
- Demo program: apictick.s
illustrates programming of the processor's Local-APIC timer interrupts
- lesson22.ppt (PowerPoint Slides)
<-- new slide added on 11/19/2008
- Demo program: betaworm.s
created for our future use in a multitasking or multiprocessing demo
- Demo program: mphello.s
illustrates Intel's 'MP Protocol' for awakening any auxilliary processors
- lesson23.ppt (PowerPoint Slides)
- Linux module: satainfo.c
creates a pseudo-file to let us discover some vital i/o-port assignments
- Demo program: satademo.s
illustrates hardware programming of the SATA disk-drive controller
- lesson24.ppt (PowerPoint Slides)
- Linux module: svgainfo.c
creates a pseudo-file to let us see the graphics frame-buffer's address
- Demo program: vesademo.s
illustrates use of the VESA BIOS Extensions for truecolor graphics
- lesson25.ppt (PowerPoint Slides)
- Demo program: trymoves.s
shows that changing lower-half of a 64-bit register affects upper-half
- Demo program: try64bit.s
takes the processor from 'real-mode' to '64-bit mode' (and back again)
- lesson26.ppt (PowerPoint Slides)
- Demo program: vm86demo.s
showing steps required to enter and leave the 'Virtual-8086 mode'
- Demo program: usevm86.s
for demonstrating software emulation of some i/o-sensitive opcodes
- lesson27.ppt (PowerPoint Slides)
- Linux module: smram.c
(used to allow access to a workstation's System Management Memory)
- Demo program: issuesmi.cpp
lets a user trigger the delivery of a System Management Interrupt
- Development tool: smlayout.cpp
locates the assigned entry-points of our SMI interrupt-handlers
- Experimentation tool: smiload.cpp
loads an SMI interrupt-handler into SMRAM (classroom only)
- Demo program: smidemo.s
(experimental interrupt-handler for System Management Interrupts)
- Demo program: showcr4.s
for you to use when answering Question V on the Final Examination
- Demo program: conform.s
illustrating a direct far procedure-call to a 'conforming' code-segment
<-- added on 8/29/2010
Announcements
- Enrolled students may join the class mailing-list
here
- Project 1: Due by Tuesday, September 30, 7:30pm
- Midterm Exam 1: Tuesday, October 7
- Project 2: Due by Thursday, October 30, 7:30pm
- Midterm Exam 2: Tuesday, November 4
- FINAL EXAMINATION: Thursday, 18 December 2008, 7:30pm
Last updated on 08/29/2010