Chameleon > DevTalk

Quick question about IO ports

(1/1)

HuntMike:
Hi all,

I was wondering if it's possible to directly write to IO ports with modification of the source code?

My Assembler language experience is very limited, and the part I'm struggling with is how to address IO ports, as they are different to memory registers aren't they?

All I need to do is this: send 0x12 to IO port 0x6C and send 0x01 to IO port 0x68 whenever Chameleon boots, regardless of the OS choice... If someone could give an example of IOport addressing or know a place with more info, I'm all ears.  :)

What would be the easiest way of doing this, and would boot0 file be the best file to modify in this case?

Thanks. :)

Superhai:
assembly inb and outb.

you need

--- Code: ---outb 0x12, 0x6C
outb 0x01, 0x68

--- End code ---

if it is in a c code you can use

--- Code: ---asm("insert assembly code here" : : );
--- End code ---

i.e.

--- Code: ---asm("outb $0x12, $0x6C \n
     outb $0x01, $0x68 \n" : : );
--- End code ---

HuntMike:
Thanks for the info, I would not have managed this otherwise...

I did originally try adding my ASM code into the boot0.s and boot1.s files, but I was getting the TIMES error (too many bytes), so it turns out I had to mod the C code.

I have no experience of C, so the ASM command was a godsend.

After some more reading around I found a little subroutine, as hardcoded hex values seemed to give errors when I compiled....

--- Code: ---static inline void outbbbyte(int port, u_int8_t data) {
asm volatile("outb %0,%w1" :: "a" (data), "d" (port));
}
--- End code ---

I just fed the routine with hex values and it works great, thanks again  :)

Navigation

[0] Message Index

Go to full version