Page 1 of 1

Lock on all processors for AP startup sequence on x86

Posted: Thu Oct 16, 2014 3:18 am
by max
Hi :)

I've implemented the SMP startup sequence for the AP's in my kernel. Now inside my AP startup code, I need to have a section that is locked across all processors, so I can assign a different stack for each AP. There is only one instance of this code (in lower memory at 0x1000), so I tried to implement the lock like this:

Code: Select all

 ; Inter-core synchronization
interlock:
    dd 0x00000000

acquireLock:
    lock bts [interlock], 0
    jc acquireLock
    ret

releaseLock:
    lock btr [interlock], 0
    ret

The problem is that NASM tells me that I have an invalid combination of opcode and operands at both of the locked instructions. What is the problem here?

Thank you!

Re: Lock on all processors for AP startup sequence on x86

Posted: Thu Oct 16, 2014 3:24 am
by Brendan
Hi,
max wrote:The problem is that NASM tells me that I have an invalid combination of opcode and operands at both of the locked instructions. What is the problem here?
The problem is that NASM can't figure out the operand size you want. To fix it either do "lock bts dword [interlock], 0" or "lock bts word [interlock], 0".


Cheers,

Brendan

Re: Lock on all processors for AP startup sequence on x86

Posted: Thu Oct 16, 2014 3:32 am
by max
Thanks Brendan, that fixed it. That message is a little misleading because normally NASM will complain with operation size not specified instead of this.

Thank you!