The DOSEMU Alterer Novices Guide

Alistair MacDonald, <alistair@slitesys.demon.co.uk>

version dosemu-1.4.0

This Document is the DOSEMU Alterer Novices Guide. It is known as the DANG.


Table of Contents
1. Introduction
2. The Main group of Modules
2.1. Functions in dos.c
2.1.1. dosemu
2.2. Functions in emu.c
2.2.1. jmp_emulate
2.2.2. emulate
2.3. Remarks in emu.c
2.4. Remarks in include/emu.h
3. The Init group of Modules
3.1. Functions in base/init/init.c
3.1.1. stdio_init
3.1.2. time_setting_init
3.1.3. timer_interrupt_init
3.1.4. map_video_bios
3.1.5. map_custom_bios
3.1.6. memory_init
3.1.7. device_init
3.1.8. low_mem_init
3.1.9. version_init
3.2. Functions in base/init/config.c
3.2.1. cpu_override
3.2.2. register_config_scrub
3.2.3. unregister_config_scrub
3.2.4. config_scrub
3.2.5. config_init
3.3. Remarks in base/init/config.c
4. The DPMI group of Modules
4.1. Functions in dosext/dpmi/dpmi.c
4.1.1. dpmi_control
4.1.2. run_pm_int
4.1.3. run_pm_dos_int
4.1.4. do_default_cpu_exception
4.1.5. do_cpu_exception
4.1.6. dpmi_fault
4.2. Remarks in dosext/dpmi/dpmi.c
4.3. Items for Fixing in dosext/dpmi/dpmi.c
5. The Video group of Modules
5.1. Functions in env/video/video.c
5.1.1. video_init
5.2. Remarks in env/video/video.c
5.3. Functions in plugin/X/X.c
5.3.1. X_init
5.3.2. X_close
5.3.3. X_shm_init
5.3.4. X_shm_init
5.3.5. X_set_mouse_cursor
5.3.6. X_handle_events
5.3.7. graphics_cmap_init
5.3.8. X_set_videomode
5.3.9. set_mouse_position
5.4. Remarks in plugin/X/X.c
5.5. Functions in env/video/vgaemu.c
5.5.1. VGA_emulate_outb
5.5.2. VGA_emulate_inb
5.5.3. vga_emu_fault
5.5.4. vga_emu_init
5.5.5. vga_emu_update
5.5.6. vgaemu_switch_plane
5.5.7. vga_emu_switch_bank
5.5.8. vga_emu_find_mode
5.5.9. vga_emu_setmode
5.5.10. vga_emu_set_textsize
5.5.11. dirty_all_video_pages
5.5.12. dirty_all_vga_colors
5.5.13. changed_vga_colors
5.5.14. vgaemu_adj_cfg
5.6. Functions in env/video/vesa.c
5.6.1. vbe_init
5.6.2. do_vesa_int
5.7. Functions in env/video/attremu.c
5.7.1. Attr_init
5.7.2. Attr_get_entry
5.7.3. Attr_set_entry
5.7.4. Attr_read_value
5.7.5. Attr_write_value
5.7.6. Attr_get_index
5.8. Functions in env/video/dacemu.c
5.8.1. DAC_init
5.8.2. DAC_set_width
5.8.3. DAC_get_entry
5.8.4. DAC_set_entry
5.8.5. DAC_rgb2gray
5.8.6. DAC_set_read_index
5.8.7. DAC_set_write_index
5.8.8. DAC_read_value
5.8.9. DAC_write_value
5.8.10. DAC_get_pel_mask
5.8.11. DAC_set_pel_mask
5.8.12. DAC_get_state
5.9. Functions in env/video/crtcemu.c
5.9.1. CRTC_init
5.10. Functions in env/video/dualmon.c
5.10.1. MDA_init
5.11. Remarks in env/video/dualmon.c
5.12. Functions in env/video/vgaemu.c
5.12.1. VGA_emulate_outb
5.12.2. VGA_emulate_inb
5.12.3. vga_emu_fault
5.12.4. vga_emu_init
5.12.5. vga_emu_update
5.12.6. vgaemu_switch_plane
5.12.7. vga_emu_switch_bank
5.12.8. vga_emu_find_mode
5.12.9. vga_emu_setmode
5.12.10. vga_emu_set_textsize
5.12.11. dirty_all_video_pages
5.12.12. dirty_all_vga_colors
5.12.13. changed_vga_colors
5.12.14. vgaemu_adj_cfg
5.13. Functions in env/video/instremu.c
5.13.1. instr_len
5.13.2. instr_sim
5.13.3. instr_emu
6. The New_Keyboard group of Modules
6.1. Functions in plugin/kbd_unicode/serv_xlat.c
6.1.1. compute_keynum
6.1.2. translate_key
6.1.3. put_rawkey
6.1.4. move_keynum
6.1.5. keysym_to_keynum
6.1.6. move_key
6.1.7. put_symbol
6.1.8. put_modified_symbol
6.1.9. get_shiftstate
6.1.10. set_shiftstate
6.2. Functions in plugin/kbd_unicode/keyb_clients.c
6.2.1. keyb_client_init
6.3. Functions in plugin/kbd_unicode/keyb_none.c
6.3.1. none_probe
6.4. Functions in plugin/kbd_unicode/keyb_raw.c
6.4.1. raw_keyboard_init
6.4.2. raw_keyboard_reset
6.5. Functions in plugin/term/keyb_slang.c
6.5.1. setup_pc_scancode_mode
6.5.2. exit_pc_scancode_mode
6.5.3. do_pc_scancode_getkeys
6.5.4. slang_keyb_init()
6.5.5. slang_keyb_probe()
7. The Misc group of Modules
7.1. Functions in base/async/int.c
7.1.1. int1a
7.1.2. ms_dos
7.1.3. run_caller_func(i, revect)
7.1.4. DO_INT
7.1.5. setup_interrupts
7.1.6. int_vector_setup
7.2. Remarks in base/async/int.c
7.3. Functions in arch/linux/async/sigsegv.c
7.3.1. dosemu_fault(int, struct sigcontext_struct);
7.3.2. print_exception_info
7.4. Functions in arch/linux/async/signal.c
7.4.1. NEWSETQSIG
7.4.2. SIG_init
7.4.3. signal_init
7.4.4. handle_signals
7.4.5. SIGNAL_save
7.4.6. SIGIO_call
7.5. Remarks in arch/linux/async/signal.c
7.6. Functions in base/misc/disks.c
7.6.1. disk_init
7.7. Functions in base/dev/misc/timers.c
7.7.1. initialize_timers
7.7.2. timer_tick
7.7.3. do_sound
7.7.4. timer_int_engine
7.8. Functions in base/misc/dos2linux.c
7.8.1. run_unix_command
7.9. Functions in base/misc/ioctl.c
7.9.1. io_select_init
7.9.2. add_to_io_select
7.9.3. remove_from_io_select
7.10. Functions in base/dev/misc/lpt.c
7.10.1. printer_init
7.11. Functions in base/dev/misc/pci.c
7.11.1. pci_read_header
7.11.2. pci_setup
7.12. Functions in base/dev/misc/joystick.c
7.12.1. joy_latency_over
7.12.2. joy_emu_button_set
7.12.3. joy_emu_axis_set
7.12.4. joy_emu_axis_conv
7.12.5. joy_linux_process_event
7.12.6. joy_linux_read_events
7.12.7. joy_linux_read_status
7.12.8. joy_linux_read_buttons_(family)
7.12.9. joy_linux_read_axis_(family)
7.12.10. joy_bios_read
7.12.11. joy_port_inb
7.13. Remarks in base/dev/misc/joystick.c
7.14. Items for Fixing in base/dev/misc/joystick.c
7.15. Remarks in include/doshelpers.h
8. The CPU_Intel group of Modules
8.1. Functions in emu-i386/cpu.c
8.1.1. cpu_trap_0f
8.1.2. cpu_setup
8.2. Functions in emu-i386/ports.c
8.2.1. port_inb(ioport_t port)
8.2.2. port_outb(ioport_t port, Bit8u byte)
8.2.3. port_inw(ioport_t port)
8.2.4. port_outw(ioport_t port, Bit16u word)
8.2.5. port_ind(ioport_t port)
8.2.6. special_port_inb,special_port_outb
8.2.7. port_init()
8.2.8. extra_port_init()
8.2.9. port_register_handler
8.2.10. set_ioperm
8.3. Remarks in emu-i386/ports.c
8.4. Items for Fixing in emu-i386/ports.c
8.5. Functions in emu-i386/do_vm86.c
8.5.1. vm86_GP_fault
8.5.2. run_vm86
8.5.3. loopstep_run_vm86
8.6. Remarks in emu-i386/do_vm86.c
8.7. Functions in emu-i386/cputime.c
8.7.1. GETcpuTIME
8.7.2. GETusTIME(sc)
8.7.3. GETtickTIME(sc)
8.7.4. GETusSYSTIME()
8.8. Remarks in emu-i386/cputime.c
8.9. Functions in emu-i386/simx86/sigsegv.c
8.9.1. dosemu_fault(int, struct sigcontext_struct);
9. The Serial group of Modules
9.1. Remarks in base/serial/ser_defs.h
9.2. Functions in base/serial/ser_init.c
9.2.1. serial_init
9.3. Items for Fixing in base/serial/ser_init.c
9.4. Functions in base/serial/ser_ports.c
9.4.1. do_serial_in
9.4.2. do_serial_out
9.5. Items for Fixing in base/serial/ser_ports.c
9.6. Functions in base/serial/ser_irq.c
9.6.1. serial_int_engine
9.6.2. pic_serial_run
9.6.3. serial_run
9.7. Remarks in base/serial/ser_irq.c
9.8. Items for Fixing in base/serial/ser_irq.c
9.9. Functions in base/serial/int14.c
9.9.1. int14
9.10. New Ideas for base/serial/int14.c
9.11. Items for Fixing in base/serial/fossil.c
9.12. Items for Fixing in include/serial.h
10. The Mouse group of Modules
10.1. Functions in base/mouse/mouse.c
10.1.1. mouse_init
10.2. Remarks in base/mouse/mouse.c
11. The Bios group of Modules
11.1. Functions in base/bios/hlt.c
11.1.1. hlt_init(void)
11.1.2. hlt_handle()
12. The PIC group of Modules
12.1. Functions in base/dev/pic/pic.c
12.1.1. pic_print
12.1.2. write_pic0,write_pic1
12.1.3. read_pic0,read_pic1
12.1.4. pic_seti
12.1.5. run_irqs
12.1.6. do_irq
12.1.7. pic_resched
12.1.8. pic_request
12.1.9. pic_iret
12.1.10. pic_watch
12.1.11. pic_pending
12.1.12. pic_activate
12.1.13. pic_sched
12.2. Remarks in base/dev/pic/pic.c
13. The Sound group of Modules
13.1. Functions in dosext/sound/sound.c
13.1.1. sb_io_read
13.1.2. adlib_io_read
13.1.3. mpu401_io_read
13.1.4. sb_io_write
13.1.5. sb_dsp_write
13.2. Remarks in dosext/sound/sound.c
13.3. Items for Fixing in dosext/sound/sound.c
13.4. Remarks in base/dev/dma/dma.c
13.5. Items for Fixing in base/dev/dma/dma.c
14. The FileAccess group of Modules
14.1. Remarks in dosext/mfs/mfs.c
14.2. Items for Fixing in dosext/mfs/mfs.c
15. And Finally ...

1. Introduction

This document is the preliminary draft of a manual to help people understand the inner workings of dosemu. It is the goal of this document to create new dosemu hackers. This concept was inspired by the linux kernel hackers guide.

This Guide was concieved and originally written by "Corey Sweeney" <corey@interaccess.com>. It has been completely revised. It is now generated automatically directly from the source code. Special thanks to "James B. MacLean" <macleajb@ednet.ns.ca> for supplying the original information. (It was mostly ripped out of a mail message.) "Jochen Hein" has made many useful comments & suggestions.

At the end if this document is a section detailing how this guide is put together. This may help you when trying to locate the relevant pieces of code. If you add new code, it would be useful if the relevant markers are added where appropriate.

This file is a collective effort. If you don't like one of the explanations, or want to add anything, please send me something!