[video member=miotatsu stream_platform=twitch project=riscy title="Bit Twiddling Confusion" vod_platform=youtube id=xS_s23rxHqg annotator=Miblo] [0:07][Mention the poll[ref site=Twitter page="Poll: Should I hire an artist to make better thumbnails for my content?" url=https://twitter.com/hmn_riscy/status/833911733752385536]] [2:42][Recap and set the stage for the day] [3:56][Embark on understanding PLIC_enable_interrupt()[ref site="SiFive Developers" page="Freedom E310-G000 Manual" url=https://www.sifive.com/documentation/chips/freedom-e310-g000-manual/]][:research] [7:32][Consult demo_gpio.c for a use case of PLIC_enable_interrupt()][:research] [12:18][Consult env/hifive1.h for the INT_DEVICE_BUTTON_* and BUTTON_*_OFFSET defines][:research] [16:15][Consult PLIC_enable_interrupt() in conjunction with the FE310-G000 Interrupts and the SiFive PLIC Register Map table[ref site="SiFive Developers" page="E3 Coreplex Manual" url=https://static.dev.sifive.com/pdfjs/web/viewer.html?file=https://static.dev.sifive.com/SiFive-E3-Coreplex-v1.2.pdf]][:research] [19:06][Calculating the value of INT_DEVICE_BUTTON_0 and the result of shifting it >> 3][:blackboard :research] [21:50][Hunt for more information about the GPIO pins][:research] [24:58][Summarise what current_ptr is being set to and move on to working out how the current mask works][:research] [27:47][The current mask][:blackboard :research] [31:38][0x17 >> 3][:blackboard :research] [33:06][@miblo][It's 128, according to: printf("%d\\n", 1 << (0x17 & 0x7));] [37:41][The AND operator][:math] [38:45][Realise that it should be in hex][:research] [39:08][@miblo][It's not 7 and 17, though, it's 0x7 and 0x17] [39:52][The current mask, take #2][:blackboard :research] [43:05][@miblo][I think you should be shifting up the 1 by 0b00111 bits, if that makes a difference] [43:17][The current mask, take #3][:blackboard :research] [44:43][The address of current_ptr][:blackboard :research] [47:27][@miblo][We're doing 0x17 >> 3? This does equal 2, apparently] [48:20][Our conceptual understanding of PLIC_enable_interrupt()][:research] [52:23][@miblo][I think it's moving the current_ptr to one of the target 1 enables, i.e. the third one, or 0x0C002082 (with 0x0C002080 being the first target 1 enable)] [53:24][Target Enable 0 at 0x0C002082 in :memory, and the relative location of current_ptr][:blackboard :research] [58:49][Consult the FE310-G000 Interrupts and consider which bit PLIC_enable_interrupt() is setting] [59:34][@azolotko][source & 0x7 can produce values from 0 to 7 depending on value of source. So the shift may vary, it doesn't have to be exactly 7] [1:00:16][What PLIC_enable_interrupt() does for source 0x8, to compare with the previous 0x17][:blackboard :research] [1:07:19][Consider that it's computing the correct thing for gpio0, and look back at the 0x17 example][:blackboard :research] [1:12:38][@miblo][What is current set to?] [1:14:30][We are out of time for today] [/video]