The DOSEMU Alterer Novices Guide

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

version dosemu-1.1.3.7

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. Functions in include/emu.h
2.4.1. NEWSETQSIG
2.5. Remarks in include/emu.h
3. The Init group of Modules
3.1. Functions in base/init/init.c
3.1.1. dosemu_banner
3.1.2. stdio_init
3.1.3. time_setting_init
3.1.4. timer_interrupt_init
3.1.5. hardware_setup
3.1.6. map_video_bios
3.1.7. map_hardware_ram
3.1.8. map_custom_bios
3.1.9. bios_mem_setup
3.1.10. memory_init
3.1.11. device_init
3.1.12. low_mem_init
3.1.13. version_init
3.2. Items for Fixing in base/init/init.c
3.3. Functions in base/init/config.c
3.3.1. cpu_override
3.3.2. config_defaults
3.3.3. register_config_scrub
3.3.4. unregister_config_scrub
3.3.5. config_scrub
3.3.6. config_init
3.4. 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. do_default_cpu_exception
4.1.4. do_cpu_exception
4.1.5. dpmi_fault
4.2. Remarks in dosext/dpmi/dpmi.c
4.3. Items for Fixing in dosext/dpmi/dpmi.c
4.4. New Ideas for dosext/dpmi/dpmi.c
4.5. Functions in dosext/dpmi/msdos.h
4.5.1. msdos_pre_extender
4.5.2. msdos_post_extender
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 env/video/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. X_setmode
5.3.10. X_update_screen
5.3.11. set_mouse_position
5.4. Remarks in env/video/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. vga_emu_set_text_page
5.5.13. dirty_all_vga_colors
5.5.14. changed_vga_colors
5.5.15. 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. vga_emu_set_text_page
5.12.13. dirty_all_vga_colors
5.12.14. changed_vga_colors
5.12.15. 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 Old_Keyboard group of Modules
7.1. Remarks in plugin/keyboard/keymaps.c
7.2. Functions in plugin/keyboard/serv_xlat.c
7.2.1. putrawkey
7.2.2. putkey
7.2.3. set_shiftstate
7.3. Functions in plugin/keyboard/keyb_raw.c
7.3.1. raw_keyboard_init
7.4. Functions in plugin/keyboard/keyb_slang.c
7.4.1. slang_keyb_init()
8. The Misc group of Modules
8.1. Functions in base/async/int.c
8.1.1. DEFAULT_INTERRUPT
8.1.2. ms_dos
8.1.3. run_caller_func(i, from_int)
8.1.4. DO_INT
8.1.5. setup_interrupts
8.1.6. int_vector_setup
8.2. Remarks in base/async/int.c
8.3. Functions in arch/linux/async/sigsegv.c
8.3.1. dosemu_fault(int, struct sigcontext_struct);
8.3.2. print_exception_info
8.4. Functions in arch/linux/async/signal.c
8.4.1. SIG_init
8.4.2. signal_init
8.4.3. cli
8.4.4. sti
8.4.5. handle_signals
8.4.6. SIGNAL_save
8.4.7. SIGIO_call
8.5. Remarks in arch/linux/async/signal.c
8.6. Functions in base/misc/disks.c
8.6.1. disk_init
8.7. Functions in base/dev/misc/timers.c
8.7.1. initialize_timers
8.7.2. timer_tick
8.7.3. do_sound
8.7.4. timer_int_engine
8.8. Functions in base/misc/shared.c
8.8.1. shared_qf_memory_init
8.9. Remarks in base/misc/shared.c
8.10. Functions in base/misc/dos2linux.c
8.10.1. run_unix_command
8.11. Functions in base/misc/ioctl.c
8.11.1. io_select_init
8.11.2. add_to_io_select
8.11.3. remove_from_io_select
8.12. Functions in base/dev/misc/lpt.c
8.12.1. printer_init
8.13. Functions in base/dev/misc/pci.c
8.13.1. pci_read_header
8.13.2. pci_read_header
8.13.3. pci_read_header
8.14. Functions in base/dev/misc/joystick.c
8.14.1. joy_reader_set
8.14.2. joy_emu_button_set
8.14.3. joy_emu_axis_set
8.14.4. joy_emu_axis_conv
8.14.5. joy_linux_process_event
8.14.6. joy_linux_read_events
8.14.7. joy_linux_read_buttons_(family)
8.14.8. joy_linux_read_axis_(family)
8.14.9. joy_bios_read
8.14.10. joy_port_inb
8.15. Remarks in base/dev/misc/joystick.c
8.16. Items for Fixing in base/dev/misc/joystick.c
8.17. Remarks in include/doshelpers.h
9. The CPU_Intel group of Modules
9.1. Functions in emu-i386/cpu.c
9.1.1. cpu_trap_0f
9.1.2. cpu_setup
9.2. Functions in emu-i386/ports.c
9.2.1. port_inb(ioport_t port)
9.2.2. port_outb(ioport_t port, Bit8u byte)
9.2.3. port_inw(ioport_t port)
9.2.4. port_outw(ioport_t port, Bit16u word)
9.2.5. port_ind(ioport_t port)
9.2.6. special_port_inb,special_port_outb
9.2.7. port_init()
9.2.8. extra_port_init()
9.2.9. port_register_handler
9.2.10. set_ioperm
9.3. Remarks in emu-i386/ports.c
9.4. Items for Fixing in emu-i386/ports.c
9.5. Functions in emu-i386/do_vm86.c
9.5.1. vm86_GP_fault
9.5.2. run_vm86
9.5.3. loopstep_run_vm86
9.6. Remarks in emu-i386/do_vm86.c
9.7. Functions in emu-i386/cputime.c
9.7.1. GETcpuTIME
9.7.2. GETusTIME(sc)
9.7.3. GETtickTIME(sc)
9.7.4. GETusSYSTIME()
9.8. Remarks in emu-i386/cputime.c
9.9. Functions in emu-i386/simx86/sigsegv.c
9.9.1. dosemu_fault(int, struct sigcontext_struct);
10. The Serial group of Modules
10.1. Remarks in base/serial/ser_defs.h
10.2. Functions in base/serial/ser_init.c
10.2.1. serial_init
10.3. Items for Fixing in base/serial/ser_init.c
10.4. Functions in base/serial/ser_ports.c
10.4.1. do_serial_in
10.4.2. do_serial_out
10.5. Items for Fixing in base/serial/ser_ports.c
10.6. Functions in base/serial/ser_irq.c
10.6.1. serial_int_engine
10.6.2. pic_serial_run
10.6.3. serial_run
10.7. Remarks in base/serial/ser_irq.c
10.8. Items for Fixing in base/serial/ser_irq.c
10.9. Functions in base/serial/int14.c
10.9.1. int14
10.10. New Ideas for base/serial/int14.c
10.11. Items for Fixing in base/serial/fossil.c
10.12. Items for Fixing in include/serial.h
11. The Mouse group of Modules
11.1. Functions in base/mouse/mouse.c
11.1.1. mouse_init
11.2. Remarks in base/mouse/mouse.c
12. The Bios group of Modules
12.1. Functions in base/bios/hlt.c
12.1.1. hlt_init(void)
12.1.2. hlt_handle()
13. The PIC group of Modules
13.1. Functions in base/dev/pic/pic.c
13.1.1. pic_print
13.1.2. write_pic0,write_pic1
13.1.3. read_pic0,read_pic1
13.1.4. pic_mask,pic_unmask
13.1.5. pic_seti
13.1.6. run_irqs
13.1.7. do_irq
13.1.8. pic_resched
13.1.9. pic_request
13.1.10. pic_iret
13.1.11. pic_watch
13.1.12. pic_pending
13.1.13. pic_activate
13.1.14. pic_sched
13.2. Remarks in base/dev/pic/pic.c
14. The Sound group of Modules
14.1. Functions in dosext/sound/sound.c
14.1.1. sb_io_read
14.1.2. adlib_io_read
14.1.3. mpu401_io_read
14.1.4. sb_io_write
14.1.5. sb_dsp_write
14.2. Remarks in dosext/sound/sound.c
14.3. Items for Fixing in dosext/sound/sound.c
14.4. Remarks in base/dev/dma/dma.c
14.5. Items for Fixing in base/dev/dma/dma.c
15. The FileAccess group of Modules
15.1. Remarks in dosext/mfs/mfs.c
15.2. Items for Fixing in dosext/mfs/mfs.c
16. 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!