#milkymist IRC log for Monday, 2013-10-07

--- Mon Oct 7 201300:00
ysionneaucan't you put expressions instead of constants in assembly? like mvhi r1, hi(some_symbol) + 0x4014:27
larscyou can14:27
wpwrakthere are some limitations on what you can do with external symbols, since they are resolved by the linker not the assembler14:29
ysionneauI get assembler error14:29
ysionneauError: junk at end of line14:29
larscbut why do you want to add something to the hi part of the address?14:31
ysionneauI link my kernel at address 0xc000000014:32
larscI suppose you could move the math to the linker script14:33
ysionneaubut for some low level subroutines I need to use the physical addresses14:33
ysionneauso subtract 0xc000 and add 0x400014:33
larsccrazy stugg14:33
ysionneaumaybe, but I did not find a better way (for now)14:34
larscbut as I said you can probably do this in the linker script "some_address_phys = some_address + 0x400000"14:34
ysionneauoh ok via the PROVIDE stuff?14:36
ysionneauPROVIDE( physical_XX = XX - a + b)14:36
larscnot sure, that is maybe a bsd specific thing14:36
ysionneauit was used in milkymist original linker script I think14:37
ysionneauto compute the stack start address14:37
larscah ok14:37
larscPROVICE(...) is like ...14:38
ysionneauoh, ok, cool14:38
larscbut it will only declare the symbol only if it is referenced14:38
larscone only to many14:38
ysionneauhum ok that's what I'm reading14:39
ysionneautoo bad I need to add something to the linker script14:39
ysionneauit does not seem very clean14:39
ysionneauthe code should be self sufficient :(14:39
ysionneaumoreover my symbol I am referencing is in the same .S file14:40
larscbut the position is still only known on link time14:40
ysionneauoh, right14:41
larscbut why do you need the real addr again?14:41
ysionneaubecause I'm calling a function with MMU off14:41
ysionneauit's in the TLB miss handler14:42
larscBut the same function can be called with MMU on as well?14:42
ysionneauhumm I don't think I will need to call it from "MMU on" context14:42
larscor well, the symbol can be access with MMU on?14:42
ysionneauIn fact I don't even need to put hi(symbol_name) + A -B, I can put the physical address directly, I know it14:43
ysionneauit wo't change14:43
ysionneaubut it's more clean that way14:43
larscyou could create a special section for stuff that's running with the mmu off14:44
ysionneauthe thing is, I'm not loading the ELF file in qemu14:49
ysionneauI'm doing objcopy -Obinary14:49
ysionneauand I'm loading it as a BIOS file14:49
ysionneauI modified Qemu to load the BIOS file at 0x4000 0000 instead of 0x86****14:49
ysionneauthat's not something to commit in any way, but it allows me to test my kernel stuff easily14:50
ysionneaumore easily than loading a bios and then transfering the kernel14:50
ysionneauqemu loads the kernel in memory at the right place for me :)14:51
ysionneaumaybe mwalle would have a better idea to do this kind of thing in a clean way14:51
ysionneauping mwalle :)14:51
larscand the kernel creates a mapping in the MMU at 0xc0000000?14:51
ysionneauI plan on doing the boot in 2 phases14:51
larscusually the kernel runs at a static mapping, so you do not get these kinds of problems14:52
ysionneauone that automatically resolves misses by updating the TLB with virt->virt-0xc000+0x4000 mapping14:52
ysionneauand then when the pmap (virtual memory subsystem) has initialized the kernel page table page14:52
ysionneauI switched to the real tlb miss handler14:53
ysionneauwhich does the real normal job of checking if the virtual address is really mapped to something and updates the TLB accordingly14:53
ysionneau16:52 < larsc> usually the kernel runs at a static mapping, so you do not get these kinds of problems < that's the case here, the kernel will always be physically at 0x4000*** and virtually at 0xc00014:54
ysionneauif I understand what you mean by "static mapping"14:54
larscbut you can't run it at 0x40000000 when the mmu is on?14:55
ysionneauif I want to do something like 3G/1G14:56
larscI think there is a design flaw somewhere when you need to switch between multiple address spaces14:56
ysionneauI need to map all the kernel stuff at >= 0xc000 000014:56
larscI see14:56
ysionneaubecause kernel is also mapping in process context14:56
ysionneaueven if process cannot access it14:56
ysionneauis also mapped*14:57
larscand it is not possible to retain the 0xc0000000 mapping when the mmu is "off"?14:57
ysionneauI mean, the virtual memory context of any user space process contains the kernel mappings (at >= 0xc000 0000), because then there is no context switch14:58
ysionneauwhen going into syscalls etc14:58
ysionneauyou can use the memory mapping of the process to access kernel stuff (and run kernel code)14:58
ysionneau16:57 < larsc> and it is not possible to retain the 0xc0000000 mapping when the mmu is "off"? < when MMU is off addresses are not translated, and 0xc000 is not in SDRAM15:01
ysionneaufor code most of the time it's OK15:01
ysionneausince most of the code is like PIC15:01
ysionneauexcept for big jumps15:01
ysionneaubut for load and stores ...15:01
larscyea, no pic stores and loads15:03
ysionneauall of this is kind of hackish ...15:03
ysionneaubut the more I read kernel code the more I think all low level MD parts are kind of hackish anyway15:04
larsconly in the bsd land ;)15:04
ysionneauOpenRISC is doing this kind of trick for instance (the 2 phases boot) for their linux port15:04
ysionneauahah no15:04
ysionneaubsd code is very clean15:04
ysionneauOpenRISC rewrites the code of the TLB miss handler15:05
ysionneauwhich is just a jump15:05
ysionneauto make the jump go to the second miss handler15:05
ysionneauthat can sound hackish as well15:05
ysionneaubut ... who cares, as long as it works15:05
ysionneauand it helps a lot to have a dummy miss handler during the bootstrap15:06
ysionneaufor LM32 I could use two memory zones for the handlers by playing with EBA...15:06
ysionneaubut I think it's even more hackish15:06
ysionneauand it wastes even more memory15:06
mwalleysionneau: why dont you use the -kernel parameter?16:45
ysionneaumwalle: because I need to link my kernel to its virtual address17:17
ysionneaunot its physical address17:17
ysionneauthen in the ELF, all addresses are like 0xc000****17:18
ysionneaumaybe I missed something, but I think qemu cannot load the generated ELF, since it thinks RAM is 0x40000000->0x48000017:19
ysionneautell me if I'm telling bullshit :)17:21
mwalleysionneau: mh, how does the linux kernel do it?17:45
larscdoes not use the mmu17:46
mwallelarsc: on other architectures17:48
mwallemhh and isnt there a load address for each elf segment?17:55
larscdoesn't need to switch17:55
mwallelarsc: iirc, on arm the mmu is turned off (if turned on) by the bootloader and the memory base is 0x017:56
larscturned off if turned on?18:00
mwallelarsc: if the bootloaded uses the mmu it is turned off before starting the operating system18:01
mwalleif it is not used it remains disabled18:02
mwalleysionneau: "$(CROSS)readelf -l netbsd_kernel" should print the virtaddr and physaddr of the elf file18:03
mwalleand arm does not have fancy features like mips where some segements are remapped to 0x0 like kseg2, does it?18:05
larscI don't think so18:07
Action: ysionneau back from diner19:25
ysionneau19:45 < mwalle> ysionneau: mh, how does the linux kernel do it? < I honestly don't know :(19:29
ysionneaumwalle: oh great, readelf -l tells me virt address == phys address == 0xc0******19:43
ysionneauI wonder how I can specify 0x4000**** as physical address19:43
Action: ysionneau starts reading linker options20:04
davidc__ysionneau: usually with the 'AT' stuff (checkout embedded arm linker scripts for .data)20:05
ysionneauhum this kind of stuff ? http://www.math.utah.edu/docs/info/ld_3.html#SEC1820:10
ysionneauso I can use AT ( 0x40000000 ) for the first (.text) section20:15
ysionneauand then for the following ones I do like AT ( ADDR(.previous_section) + SIZEOF(.previous_section) )20:15
ysionneauhum it did not change the load address :o20:18
ysionneauok the build system did not run the linker since I modified no code line20:23
ysionneaunow it fails to link :)20:23
--- Tue Oct 8 201300:00

Generated by irclog2html.py 2.9.2 by Marius Gedminas - find it at mg.pov.lt!