Port-amiga archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bus_space(9) - amiga specific questions
Hello.
For a few months, as my time permits, I'm working to deepen my knowledge of the
NetBSD kernel. Particularly of amiga and amigappc ports. There are still many
cool devices which are not supported by NetBSD. I'd gladly change this
situation by writing more drivers, but I feel that my foo is still not strong
enough. I'd like someone verify my knowledge regarding bus_space on amiga port.
1. Mapping the bus space
Lets assume that hardware has two interesting registers, at 0xdff1f0 and
0xdff1f4. The registers are 16-bit. I'd write the following code to map it:
#define FOOHW_BASE 0xdff1f0
#define REG0_OFF 0x0
#define REG1_OFF 0x1 /* actually 0x4 but accessed using stride_4
*/
struct bus_space_tag foo_bst;
bus_space_tag_t foo_iot;
bus_space_handle_t foo_ioh;
foo_bst.base = (u_long) ztwomap(FOOHW_BASE);
foo_bst.absm = &amiga_bus_stride_4;
foo_iot = &foo_bst;
bus_space_map(foo_iot, 0, 4, 0, foo_ioh);
Is the above code correct?
Should bus_space_map argument 3 (size) be divided by stride? Or should I
specify "real" size there?
2. Writing/reading the registers
If I wanted to read 0xdff1f0 and then 0xdff1f4, I'd write:
uint16_t reg0 = bus_space_read_2(foo_iot, foo_ioh, REG0_OFF);
uint16_t reg1 = bus_space_read_2(foo_iot, foo_ioh, REG1_OFF);
3. More about strides
The amiga_bus_stride_1 defines bus stride of "1 byte per word". Word means 2
bytes, right?
Additionally, amiga_bus_stride_2 defines bus stride of 1 byte per 2 words. The
comment in amiga_bus_simple_2word.c again says "1 byte per word" but I guess
that is an error and it should be "1 byte per 2 words" ?
Also, amiga_bus_stride_4 defines bus stride of "1 byte per long", as comment
states. On an amiga 2 words equals 1 long (32-bit), but amiga_bus_stride_4 is
defined as a method operating on words, so that would be 1 byte per 4 words?
I'm really confused, I always thought it's 1 byte per 4 bytes, but now I'm not
really sure.
4. Misc
What does bus_space_handle_t really contain on amiga? I assume it's a pointer
to the mapped (virtual) address? Is it normal for it to reside somewhere around
0x69xxx ?
Can I use physical addresses to read or write data to registers when in DDB?
--
Best regards,
Radoslaw Kujawa
Home |
Main Index |
Thread Index |
Old Index