Add an implementation of sbus-intr>cpu for sun4m to map sbus interrupt levels (1 to 7) into cpu interrupts, and make use of it for bpp. Assumes false is the same as -1.
Signed-off-by: Bob Breuer breuerr@mc.net ---
Index: arch/sparc32/tree.fs =================================================================== --- arch/sparc32/tree.fs (revision 1046) +++ arch/sparc32/tree.fs (working copy) @@ -1,4 +1,16 @@
+\ map sbus intr level to cpu intr +: sun4m-sbus-intr>cpu + \ map 1 2 3 4 5 6 7 other + \ to 32 33 35 37 39 3b 3d 0 + dup 1 7 between if + 2* dup 2 <> + h# 30 + + else + drop 0 + then + ; +['] sun4m-sbus-intr>cpu to sbus-intr>cpu + " /" find-device 2 encode-int " #address-cells" property 1 encode-int " #size-cells" property @@ -61,7 +73,7 @@ new-device " SUNW,bpp" device-name h# 4 encode-int h# 0c800000 encode-int encode+ h# 0000001c encode-int encode+ " reg" property - h# 33 encode-int 0 encode-int encode+ " intr" property + h# 2 sbus-intr>cpu encode-int 0 encode-int encode+ " intr" property finish-device [THEN]
On 15/08/11 15:28, Bob Breuer wrote:
Add an implementation of sbus-intr>cpu for sun4m to map sbus interrupt levels (1 to 7) into cpu interrupts, and make use of it for bpp. Assumes false is the same as -1.
Signed-off-by: Bob Breuerbreuerr@mc.net
Unfortunately I have no way of testing what the output should be for any given input for this function, but to my untrained eye the general patch style/location look fine. The only thing I'd like to see is a stack diagram for the sun4m-sbus-intr>cpu word at which point if no-one else objects then I'm happy to commit.
ATB,
Mark.
Mark Cave-Ayland wrote:
On 15/08/11 15:28, Bob Breuer wrote:
Add an implementation of sbus-intr>cpu for sun4m to map sbus interrupt levels (1 to 7) into cpu interrupts, and make use of it for bpp. Assumes false is the same as -1.
Signed-off-by: Bob Breuerbreuerr@mc.net
Unfortunately I have no way of testing what the output should be for any given input for this function, but to my untrained eye the general patch style/location look fine. The only thing I'd like to see is a stack diagram for the sun4m-sbus-intr>cpu word at which point if no-one else objects then I'm happy to commit.
Ah, I forgot a pointer to something resembling documentation. I used the Linux source file arch/sparc/kernel/sun4m_irq.c. To get the resulting value for intr, the low 4 bits are the PIL, and the upper 4 bits correspond to 0x30 for SBUS.
If someone could show how this C snippet might translate into forth: static const uint8_t map[7] = { 0x32, ... }; return map[sbus_level]; then I could just do an array lookup in sun4m-sbus-intr>cpu to make the mapping more obvious.
Bob
On 20/08/11 06:11, Bob Breuer wrote:
Unfortunately I have no way of testing what the output should be for any given input for this function, but to my untrained eye the general patch style/location look fine. The only thing I'd like to see is a stack diagram for the sun4m-sbus-intr>cpu word at which point if no-one else objects then I'm happy to commit.
Ah, I forgot a pointer to something resembling documentation. I used the Linux source file arch/sparc/kernel/sun4m_irq.c. To get the resulting value for intr, the low 4 bits are the PIL, and the upper 4 bits correspond to 0x30 for SBUS.
That's great - a comment within tree.fs next to the sun4m-sbus-inter>cpu would be fine for me.
If someone could show how this C snippet might translate into forth: static const uint8_t map[7] = { 0x32, ... }; return map[sbus_level]; then I could just do an array lookup in sun4m-sbus-intr>cpu to make the mapping more obvious.
Have you tried Leo Brodie's excellent "Starting Forth" book which is now available online? Have a look at the "Initializing an Array" section here: http://www.forth.com/starting-forth/sf8/sf8.html.
HTH,
Mark.
Mark Cave-Ayland wrote:
On 20/08/11 06:11, Bob Breuer wrote:
If someone could show how this C snippet might translate into forth: static const uint8_t map[7] = { 0x32, ... }; return map[sbus_level]; then I could just do an array lookup in sun4m-sbus-intr>cpu to make the mapping more obvious.
Have you tried Leo Brodie's excellent "Starting Forth" book which is now available online? Have a look at the "Initializing an Array" section here: http://www.forth.com/starting-forth/sf8/sf8.html.
Looking at CREATE, you build up a byte array one byte at a time with "c," after each byte, and the result is not const, so it's not quite what I was hoping for... However, I came across hex strings, i.e. " "(A1 B2)" will directly encode those 2 bytes into a string, which can be used as a byte array. I kinda like the hex string idea, but what's your preference?
Bob
Looking at CREATE, you build up a byte array one byte at a time with "c," after each byte, and the result is not const, so it's not quite what I was hoping for... However, I came across hex strings, i.e. " "(A1 B2)" will directly encode those 2 bytes into a string, which can be used as a byte array. I kinda like the hex string idea, but what's your preference?
The byte array isn't "const" either, in exactly the same way (some compilers might put it in ROM if so instructed, but that is true for the CREATE version as well).
The string approach is sort of hackish, for example you need to drop the length it leaves on the stack. It can be convenient for big chunks of byte data, but for something short I wouldn't bother.
Segher