flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
typedef 23 Oct 2012, 21:37
You have already started.
To use those privileged instructions you have to run in DOS mode or in ring0 usin a driver. You can try also using debug.exe to play with some ports. |
|||
![]() |
|
cod3b453 23 Oct 2012, 23:29
In general, IO mappings are derived from PCI device enumeration (this includes legacy controllers that are bridged). Each device has an identifier that should have a corresponding driver; this driver should know how to use the IO ports according the the device's specification.
The exceptions are the legacy controllers such as PIT, PIC, RTC, CMOS, PS2, ... these have fixed IO mappings but still have a specification on how to use them. I believe the speaker is driven by the PIT ![]() ---- in/out are not privileged instructions - they can actually be used in ring 3 as long as the IOPL in the TSS allows it; though, yes, most OSs disable them all. |
|||
![]() |
|
Overflowz 23 Oct 2012, 23:50
I'm using DosBox for testing, but I think you guys don't understand me.
For example, take this example: Internal Speaker How these things are happening? I though system speaker port was 61h, but for me, seems arbitrary values. I need list of values to send, to control them. Thanks! ![]() |
|||
![]() |
|
cod3b453 24 Oct 2012, 18:24
The enable is port 0x61, which is gating the output of the i8253 PIT. The signal is defined by the magic value "182" in your example, which if you read the specification, means "select channel 2, LSB then MSB, square wave mode, binary input" into port 0x43 (PIT command register). It then loads the "frequency number" (PIT channel 2 register), which is actually the clock divider of the master clock, one byte at a time LSB then MSB. The frequency is 0x1234DD/divider and divider must be 1..65535. The duration is being controlled based on how long it takes the CPU to count ~1.6M times. (It would be better to use the channel 0 or RTC IRQ for real timing)
In short, you choose when to toggle the speaker and load a divider to get the frequency you want. |
|||
![]() |
|
Overflowz 24 Oct 2012, 19:52
Okay, you gave me the little tutorial here, where can I find all the "magic values" that does something?
|
|||
![]() |
|
baldr 21 Nov 2012, 16:46
Overflowz,
No magic there, i8253/54 datasheets are available freely (even Wiki has an article about it). |
|||
![]() |
|
typedef 29 Nov 2012, 12:12
cod3b453 wrote: in/out are not privileged instructions - they can actually be used in ring 3 as long as the IOPL in the TSS allows it; though, yes, most OSs disable them all. Well then can you explain why Windows produces a "Privileged Instruction" Exception when you use in/out? Maybe I might try one day injecting a thread into user32/kernel32 and use the IN/OUT instructions because it seems like these DLLs use them all the time. // Added to TODO list. ![]() |
|||
![]() |
|
Goplat 29 Nov 2012, 17:52
typedef wrote:
Quote: Maybe I might try one day injecting a thread into user32/kernel32 and use the IN/OUT instructions because it seems like these DLLs use them all the time. |
|||
![]() |
|
baldr 30 Nov 2012, 22:11
typedef,
Your code have to have enough permissions (via IOPL or I/O permission map thru TSS) to use in/out instructions seamlessly. NTVDM (SoftPC evolved) intrusively emulates direct access to hardware ports for 16-bit code. With enough privileges you can use ready-made WinIO.Sys driver or something similar in Win32. Intel SDM/AMD APM give clear understanding when (and why) privileged instructions (such as in/out) cause #PF. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.