<klange>
> Something like the command mode in my editor would be a little better.
rustyy has joined #osdev
<klange>
Unfortuantely, this won't work directly for a shell, since it only applies to the command mode and not to scripts, which are pure Kuroko
<milesrout>
klange: i tried to do bim "$(command -v something)" when I was trying it out, which is the "proper" way to do it
<milesrout>
but i dont think it worked :P
<milesrout>
i think bim `which something` worked
<klange>
I don't know what the difference between those would be.
<milesrout>
supposedly 'which' is out of favour and you're meant to use 'command -v' in scripts, because 'which' isn't properly standardised or something
<j`ey>
milesrout: lol yeah
<klange>
if you mean in my shell it doesn't support any string interpolation of commands, or backtick
<milesrout>
i thought backtick worked but maybe im not remembering properly
<klange>
to get a command output into something usable in my shell you'd do `export-cmd SOME_VAR which something`
<clever>
milesrout: i prefer using `type` from bash
<klange>
hopefully this demonstrates how hilariously terrible my shell is
<j`ey>
klange: but it's *your* shell, and thats what matters ;)
<milesrout>
yeah type is the "blessed" way of finding out what a command does at an interactive shell prompt, I think
<milesrout>
i always just use which for everything, naughty
<j`ey>
for interactive POSIX doesnt matter I guess
<heat>
lots of scripts are bash only, POSIX doesn't matter there as well ;)
<milesrout>
if you put #!/usr/bin/env bash at the top of your script I suppose you're allowed to use bashisms
<clever>
milesrout: which can also accept an alias list on stdin i think, and be aliased so which is ran with the right args to accept that
<heat>
save yourself an exec and just use /bin/bash
<clever>
--read-functions
<milesrout>
bash isn't in /bin on all systems
<clever>
and friends, from its man page
<j`ey>
heat: nice optimisation
<heat>
it's in /bin in all sane systems
<milesrout>
it's not in bin on openbsd
<heat>
sane systems yeah
<clever>
milesrout: and the example in the man page
Ali_A has quit [Quit: Connection closed]
<milesrout>
i found this out because i put /bin/bash as the root shell in /etc/passwd or w/e and then logged out and tried to log back in.. whoops.
<klange>
compared to the old format, which shows how things work as simple commands, opened in a pre-3 bim for highlighting: https://klange.dev/bimrc.htm
<bslsk05>
klange.dev: .bimrc
<milesrout>
if I were organising the filesystem for a Unix-like operating system there would be physical separation between /bin,/lib,etc. (base system), /usr/bin,/usr/lib,etc. (packages), /usr/local/bin,/usr/local/lib,etc. (ports)
<heat>
a package and a port is the same thing
<heat>
also, what do you gain from separating things like that? it's just confusing
<klange>
if you're Linux, where everything comes from many sources, then the distinction is meaningless
<moon-child>
heat: on freebsd, a 'package' is a binary distribution, while a 'port' is a source distribution which is compiled locally. I agree there is not much to be gained by separating them
<milesrout>
personally i'm not a huge fan of the /usr/bin and /bin merge
<klange>
if you're a system like one of the BSDs, where quite a lot is part of the main source tree, then there is a clear distinction between "ports" that are from outside and what came with the system
<klange>
and if you're me, there's "stuff I wrote" and "stuff I didn't write"
<moon-child>
there's still stuff you didn't write?
<klange>
I have ports!
<moon-child>
'we are the knights who say nih!'
<klange>
On a base CD I ship libgcc as a shared object, and Deja Vu TrueType fonts.
<heat>
sure but what do you gain from keepings things separate in the filesystem?
<milesrout>
do you still use freetype etc. klange?
<heat>
instead of just /bin, /lib, /usr/include, etc
<klange>
nope wrote my own truetype rasterizer
<milesrout>
nice
<klange>
doesn't do much fancy stuff, but it's much nicer than my old thing and it at least renders Deja Vu and VL Gothic fine
<klange>
and I think the Equestria font I was using for Pony OS, but I really need to check because, uh, ~10 days.
<milesrout>
oh my god moon-child i just got that joke
<milesrout>
the knights that say NIH
<heat>
i have a burning desire to ditch my kernel's vterm for one in user-space with vulkan/opengl acceleration and most importantly, ttf fonts
<klange>
PonyOS 8 is coming. 64-bit, SMP. Rudimentary ARM support but I sure as shit am not going to have the RPi platform target working well enough...
<heat>
the other day I tried out fuchsia and their terminal has the prettiest font
<heat>
really nice font, anti-aliased and buttery smooth
* moon-child
working on gpu-accelerated ttf render
<heat>
i just have the basic bitch vga text mode font :/
<klange>
My kernel has... a very rudimentary built-in terminal emulator, as a debug fallback, which interestingly has essentially no relation to the one it _used_ to have that eventually became my userspace terminal emulator
<moon-child>
'working on' I haven't touched it in a while
<moon-child>
but I can do better than all the other shitty gpu vector renderers, so that counts for something
<milesrout>
is targeting the raspberry pi relatively easy?
<milesrout>
compared to doing amd64 i mean
<heat>
x86 is an arch, the rpis are a bunch of platforms
<klange>
It's an awkwardly documented platform even by ARM standards, and you really need a USB stack to have a usable user environment.
<milesrout>
every time i think about fiddling with osdev stuff I'm always like :/ eugh x86 is so crusty
<klange>
x86's biggest 'feature' is that it essentially _is_ a platform.
<klange>
Maybe two if you're going to separate BIOS from EFI.
<heat>
nah that's too extreme
<klange>
But for the most, every x86 box you would care about is going to be a PC. Every ARM is special and unique.
<moon-child>
yeah but not much to be done there. It's still ultimately pc
<heat>
you do have(or had) some weirder platforms on x86 though
<bslsk05>
en.wikipedia.org: PC-9800 series - Wikipedia
<heat>
there are x86 tablets
<heat>
you literally have device tree on x86
<heat>
you also have PCIe and ACPI on arm64 now
<milesrout>
i have a laptop with coreboot and seabios on it, i guess that would be a reasonble starting point...
<heat>
and riscv also has pcie
<gog>
at the very end it looks like the pressure of standardization of the broader market finally killed them
<heat>
and ACPI when booting through UEFI (which is possible)
<milesrout>
as opposed to some poorly documented half-broken board manufacturer bios that might fry my computer if i issue the wrong commands or whatever
<gog>
the last model shipped was basically a standard PC
heat has quit [Remote host closed the connection]
<klange>
oops I found a regression in my ld.so
<klange>
as part of aarch64 bringup, I made it bail on unsupported relocations, and this broke some kuroko C modules on x86-64 that had DTPOFF and DTPMOD relocs (which I didn't need to do)
<klange>
(regression discovered because I get these app window screenshots off the VM with a kuroko script that just chucks them over tcp to a waiting `nc` on the host)
<milesrout>
the middle prong of the capital E in QEMU does look a bit smeary - is that the sort of thing that is fixed by stronger hinting?
<milesrout>
i don't really know much about font rendering
<klange>
Vertical hinting would fix that, yeah; a lot of modern hinting 'improvements' have been changing hinters to only do that sort of vertical hinting and not do horizontal hinting
<klange>
hinting in truetype is... well, you know how ACPI is a massive pain because of AML? truetype was there first with hinting bytecode, a scourge so terrible it rooted the original XBox and several iPhones.
<milesrout>
hinting bytecode, huh. TIL
<clever>
and windows too i believe
<clever>
ive read a blog post, saying that win95 moved font rendering into the kernel, to cheat benchmarks
<clever>
and then fonts gained bytecode, and now fonts can gain ring0
<milesrout>
maybe the Linux kernel text console should do hinting with eBPF :D
<clever>
so now nobody uses the in-kernel font code
<j`ey>
milesrout: hah
<kingoffrance>
> kingoffrance: your idea that OSes should have different profiles is so genius i think sonny was confusing me with someone else, but i will take credit nonetheless
<clever>
milesrout: i think the linux console is using fixed sized pre-scaled fonts
<clever>
milesrout: but linux is also moving towards fbcon, which is userland rendering
<j`ey>
is that still true?
<j`ey>
moving to userland
<milesrout>
i wonder whether we really need antialiased fonts with high-DPI screens
<clever>
j`ey: i think so, things like scrollback has already been entirely removed from the kernel
<j`ey>
added back recently :P
<clever>
heh
<milesrout>
the linux console has scrollback?
<mrvn>
milesrout: if the DPI is high enough then that aliases enough. but why throw away extra quality?
<clever>
milesrout: shift+pageup
<mrvn>
milesrout: also antialias for fonts only works with high DPI
<mrvn>
milesrout: or more specifically with fonts that have a lot of pixels.
<mrvn>
+size
eddof13 has joined #osdev
* milesrout
adds metafont to his to-read-about list
<kingoffrance>
something i was going to borrow from there...word wrap algorithm or something...
<klange>
I don't have a glyph for that last one, which makes sense looking at it here in my host terminal as it clearly is a different font than the others...
X-Scale has quit [Ping timeout: 240 seconds]
X-Scale` is now known as X-Scale
<klange>
Hm, Character Map says I'm getting it from regular Deja Vu Sans... might be a broken fallback
<klange>
it works if I put it on something that uses one of the non-monospace fonts, so must be bad fallback logic somewhere - am I not falling back to non-monospace?
<klange>
I need to... redo the boot screen, replace or remove Misaka's logo renderer or at least make it pink, probably should make the panel pinkish again... and get that lovely font back.
<klange>
Oh and a rainbow or pink bim theme would be nice.
<klange>
sitting here banging my head trying to figure out why my panel colors were still blue despite changing the header, touching the files, rebuilding...
<klange>
I'm using a toolchain from another directory and it was pulling the headers from that one because sysroots
<klange>
Ah and I also wanted to port ponysay to Kuroko.
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<klange>
the bootsplash and kernel render the Misaka T logo procedurally, with a simple gradient definition and a layout of squares crammed into a 64 bit int
<sonny>
Why have spaces in filenames etc, when you can add another metadata field for the title/name of the file?
<klange>
On macOS, files can have / in their names. This is handled by intermediary layers in userspace and is actually stored as :, which means : can't appear in a file name.
<mrvn>
while the world over can't have / but does have : in filenames.
<sonny>
I think the separator character should be metadata as well
<gog>
how?
<mrvn>
sonny: you intent to use something other than /?
<gog>
like say you need an absolute path
<sonny>
mrvn no, but what prevents you from changing the delimiter
<sonny>
gog: go on
<mrvn>
incompatibility with basically everything
<gog>
how do you tell the system that you're trying to open a file at say
<mrvn>
if it's metadata then in foo/bar/baz/blub/blubber I will give each component a different separator. Won't that be fun?
<gog>
(root) -> home -> user -> config -> file
<mrvn>
gog: that part is easy: array of strings
<gog>
i guess you could have system libraries accept only arrays of strings as paths
<gog>
and then give whatever separator to functions that decompose paths
<gog>
but that's like
<mrvn>
The problem is: how does any app create such an array from user input?
<klange>
mrvn: Only certain things actually do the :/ switcheroo, such as Finder.
<mrvn>
klange: so it's basically : but some GUIs display it as / to be contrary.
<klange>
basically, but it's codified and expected and there's even default files with / in their names
<milesrout>
that's crazy
<mrvn>
Say the user inputs "/home/user/config/file". Now the app has to check the metadata of / so see what the separtator is, It's '/', ok. So first component is home. What's the sepeartor of home? Still '/', so next it's user. What's the separator for user? ... insane.
<klange>
macOS abhors files paths; things that still accept them will use : in place /
<klange>
the whole thing is a remnant of classic Mac OS that used : as the path separator
[itchyjunk] has quit [Ping timeout: 268 seconds]
<mrvn>
dos/windows used <letter>:\ for drives, AmigaOS used <name>: for volumes. : in filenames is still a problem on some systems.
<mrvn>
but I don't know anything that doesn't support / as spearator nowadays.
<mrvn>
I guess we should be using std::path::preferred_separator
[itchyjunk] has joined #osdev
<milesrout>
maybe we should use :: as a path separator
<klange>
should I do something special for "PonyOS 8"? maybe a Mac OS 8 theme, or a Windows 8 theme?
<milesrout>
::usr::local::bin::bash
<sonny>
mrvn I wasn't thinking of the separator metadata in the file itself, just the name/title
<kingoffrance>
https://en.wikipedia.org/wiki/Venti A 160-bit SHA-1 hash of the data (called score by Venti) acts as the address of the data https://en.wikipedia.org/wiki/Fossil_(file_system) Plan 9 allows modifying the namespace in advanced ways, like redirecting one path to another path (e.g. /bin/ls to /archive/2005/1012/bin/ls) something like that :) ?
<bslsk05>
en.wikipedia.org: Venti - Wikipedia
<bslsk05>
en.wikipedia.org: Fossil (file system) - Wikipedia
<kingoffrance>
i think there is two levels here: how to retrieve data (contents, in this case hash) how to point at that data with a "friendly" name(s). every filesystem does these things, and may also allow "hard links" or symlinks "arity" "aliases". or magic symlinks :D
<kingoffrance>
in other words, a name is always a pointer
srjek has quit [Ping timeout: 250 seconds]
<kingoffrance>
(magic symlink adds another level of indirection)
<kingoffrance>
(i am against the idea until you acknowledge magic symlink)
* kingoffrance
points at SICP cover, whispers, "magic symlink"
<moon-child>
a name is a _weak_ pointer
<sonny>
why weak?
<sonny>
oh
<sonny>
iswym
Brnocrist has quit [Ping timeout: 252 seconds]
<kingoffrance>
agree ; what i was getting at: the hash (or whatever other scheme) are also "names". in above scheme, " In other words, it does not participate in reference counting to delete an object or extend its lifetime" is "cannot delete" "permanent"
<kingoffrance>
to me it looks like <block 0, disk 1, hardcoded location "machine-friendly name"> <- [content-addressable "machine-friendly name"] <- [human friendly name] <- [dynamic magic human friendly name] thus even without the content-addressable "hash" scheme thats like 4 potential layers of names IMO
<kingoffrance>
err, remove the "content-addressable" still 2-3 layers going on
<clever>
ipfs has 2 sides to it
<clever>
the file storage, is a merkle tree, where blocks have a max size, are identified by a hash of the value, and a block can contain block hashes to concat together
<clever>
and directories, are just name and hash pairs, much like git, and stored the same way
<clever>
then you have the ipns half, where you map a public key to a directory object hash
<clever>
and the private can change that mapping
<clever>
so a given keypair, has an entry-point it can change, and that then contains an immutable tree of files
<clever>
and by creating a new tree (much like zfs and git) and changing the root pointer, you can modify any file
<clever>
but deletion is purely by reference tracing and garbage collection
<clever>
distribution and duplication is kinda lacking, its entirely a pull model
<clever>
if somebody wants an object, they pull a copy, and then share it like torrents
<clever>
until they GC their own local copy
<sonny>
clever: in the web clients the name is always a hash?
<clever>
sonny: it can be both, you always need a hash at the front, and if the hash refers to a directory, it can be followed by a normal set of / seperated names like a path
<sonny>
oh ok
<clever>
and if the final element isnt a file, the web client will show a directory listing
<clever>
like any static file http server
<clever>
the biggest negative i see with ipfs, is 2 factors
<clever>
1: there is a major lack of privacy, a node has a keypair, and its pubkey+ip are stored in a DHT when online
<clever>
so if i know your pubkey, i can track your pubip at all times
<clever>
2: there is no push mechanism, so your only ever hosting files you care about, and consumers may help, if they dont gc
<sonny>
clever: yeah, a listing of names with hashes sucks to navigate though
<clever>
the DHT also maps objectid -> node pubkey, so you can search for every pubkey owning a given object, and then you can query the IP of those nodes
<clever>
sonny: the hashes only serve as a root, and once you input a single hash, you have a normal directory tree, with normal ascii names
<sonny>
ohhh
<sonny>
that makes a lot more sense then
<clever>
the directory object maps those english (if you choose) names to hashes
<clever>
like git does
<sonny>
I fiddled around with a few ipfs sites and I had no idea what I was doing
<energizer>
clever: what is the use case for pushing files to people who don't particularly want them?
<clever>
energizer: yeah, thats kind of why it lacks push
<clever>
somebody has to pay for the storage
<energizer>
but you said it's a negative
<clever>
thats something i would want in a storage solution, like aws s3
<clever>
but ipfs doesnt really store, it only connects storage to clients
<clever>
so you still have to run the storage somewhere, either yourself, or as a service you rent
<energizer>
that is a service that takes a PUT, saves the file in ipfs, and returns the ipfs hash?
<clever>
energizer: it could also just be a service that takes an ipfs hash, pulls it from anywhere (potentially your local node), and then adds a GC root
<clever>
so you dont have to invent a new upload protocol, you create the ipfs objects locally
<energizer>
i see
<clever>
also, instead of each chunk in the merkle tree being max-size
<energizer>
but then you have to invent a service discovery protocol or something?
<clever>
they could be oraganized as logical records
<clever>
so appending is cheaper
<clever>
by letting you reuse the leaf nodes with data
vdamewood has joined #osdev
<clever>
you could also break a zip file or tar file up by the sub-files within
<clever>
so if you make a different tar with some files in common, it can still dedup
<bslsk05>
www.reddit.com: Hreddit noćna mora 20.03.2022. : croatia
<zid>
anyone speak croatian? :P
xenos1984 has joined #osdev
ElectronApps has joined #osdev
CaCode has quit [Read error: Connection reset by peer]
Ali_A has joined #osdev
Ali_A has quit [Quit: Connection closed]
Coldberg has quit [Ping timeout: 252 seconds]
Ali_A has joined #osdev
sonny has quit [Quit: Client closed]
vdamewood has quit [Read error: Connection reset by peer]
vdamewood has joined #osdev
C-Man has joined #osdev
dormito has quit [Quit: WeeChat 3.3]
[itchyjunk] has quit [Read error: Connection reset by peer]
<jjuran>
zid: I know someone who does, why?
elastic_dog has quit [Ping timeout: 240 seconds]
jjuran has quit [Quit: Killing Colloquy first, before it kills me…]
jjuran has joined #osdev
elastic_dog has joined #osdev
<zid>
because.. of the link I posted a quarter of a second before I said it
dormito has joined #osdev
gog has joined #osdev
milesrout has quit [Changing host]
milesrout has joined #osdev
dormito10 has joined #osdev
dormito has quit [Ping timeout: 268 seconds]
bgs has joined #osdev
jeaye has quit [Quit: WeeChat 3.1]
dormito has joined #osdev
Ali_A has quit [Quit: Connection closed]
dormito10 has quit [Ping timeout: 252 seconds]
<klange>
after much difficulty, I have finally managed to get an actual real xhci controller to run a command ring...
<gog>
yay!
<j`ey>
x86 or arm?
<klange>
arm
<j`ey>
very cool!
<klange>
I already had things working in QEMU on x86, though I don't have a USB _stack_ of any sort yet, just was playing around with top-level controller pokery
<klange>
And it was a struggle to get it working on the rpi, even when I also had the PCIe bringup going well enough to get to the card - spent all day struggling to figure out why the hci wasn't get any of the data I had to allocate memory for, or why it would randomly just shortly after I turn it on
<klange>
I don't actually know what exactly was a problem or not, but at least it seems like the main thing was I was trying to do 64-bit register writes when this hci really wants 32-bit only... and maybe also I was missing some pcie setup, this thing is all voodo
<klange>
I need a break... one more day off tomorrow, can spend it actually setting up the 2.0 hub and see if I can get device strings from the keyboard
<klange>
The rpi400 has one 2.0 port and 4 3.0 ports on the HCI, and then all the 2.0 lines are attached to a hub on that one port.
<klange>
I've poked at the port status regs and I can turn things on, even was able to find a USB 3 stick and plug it to see a device connect in sort-of real time
GeDaMo has joined #osdev
elastic_dog has quit [Ping timeout: 240 seconds]
<clever>
klange: i believe that 32bit limitation, is due to the pci-e controller, not the xhci controller
<clever>
and my understanding is that it has a pair of 2.0 and a pair of 3.0 ports
<clever>
one usb2 is user accessible, one usb2 goes to the holtek MCU for scanning the keyboard matrix, and both usb3 are user accessible
<clever>
i still need to look into pci-e bringup as well
<klange>
the hci says there's 4 root 3.0 ports, at least, and Linux said the hub on the 2.0 port had 4 ports of its own
<clever>
yeah, the vl805 is capable of driving 4 usb3 ports
<clever>
but the pci-e cant supply enough bandwidth to saturate that
<clever>
so rather then give an illusion of supporting 4 x usb3 worth of bandwidth, the usb3 lanes are just not wired up on 2 ports
<clever>
ive also seen evidence that some of the usb ports have the pins wired backwards, for pcb routing reasons
<zid>
I only support UHCI sorry
<clever>
and the vl805 firmware is aware of that, and deals with lane swapping
elastic_dog has joined #osdev
<clever>
that firmware also hides all of the messy stuff behind the standard xhci api
<clever>
ive also seen signs that the vl850 firmware is just 8051 asm
pretty_dumm_guy has joined #osdev
_xor has quit [Ping timeout: 256 seconds]
<GeDaMo>
CPUs all the way down :|
<klange>
I think, for now, I just want to get this keyboard to send me keys, and we'll go from there. Maybe a mouse next.
<clever>
HID is relatively simple for a usb stack
<clever>
query the descriptors, and deal with usb hubs recursively
<clever>
for each HID device, i think you just configure xhci to poll its endpoint for reports
<clever>
for bios compatible HID devices, the report structure is in the specs, and you can just assume its a certain format
<clever>
for keyboards, i think its 16 bits worth of bitmask for modifier keys, and then 4 bytes to hold the keycode for all 4 keys being held?
<klange>
i recall ben eater's walk through usb at the hardware level
<clever>
my biggest complaint with ben eaters videos, is that he was decoding the raw usb in every single video
<clever>
he never moved to using proper tools
<clever>
if you have a linux host, just `modprobe usbmon ; wireshark` and you can inspect all usb traffic on a given controller
<clever>
sure, its good to show how it works at a low level, but dont cripple the viewer by forcing them to hand decode usb forever
<klange>
the wiki says... 8 bits of modifiers flags, one dead byte, six keypress bytes, for standard report format
<clever>
the dead byte is more modifiers i believe
<clever>
but none got assigned
<clever>
for more complex HID devices, there is a report descriptor you can parse, that explains what every single bit does
<clever>
often, a device will combine both, giving the standard 8 byte report as the first 8 bytes, and then non-standard stuff after
<clever>
Bus 007 Device 004: ID 0430:00a2 Sun Microsystems, Inc. Type 7 Keyboard
<clever>
so i pop open wireshark, and sniff the usbmon7 interface
<clever>
and tapping `a` generates 4 packets, an interrupt packet on endpoint 1, with the 8 byte report
<clever>
first one had a 4 in the 3rd byte
<clever>
2nd reply had a 0 in there, to clear that key being held
<bslsk05>
www.devever.net: Myths about USB NKRO and how USB HID works
<clever>
and key repeat happns entirely host-side, no usb packets exchanged while the key is repeating
<clever>
GeDaMo: ah, thats probably what i was just quoting by memory
<clever>
so a fancy 104-key keyboard, might have just a raw 104 bit bitfield of every damn key (13 bytes), but precede that with the standard 8 byte report, so the bios can still make sense of it
<clever>
and like that page says, the report descriptor claims those 8 bytes are padding
<bslsk05>
github.com: rpi-tools/main.c at master · librerpi/rpi-tools · GitHub
<clever>
this then reads the input device in linux (from the pi400 keyboard), converts it back into an HID report, and injects it into the gadget mode HID device
<clever>
so now the pi400, is acting like a dumb usb keyboard
<clever>
wireshark will also capture and decode all of the usb descriptors when you plug a device in, so you can get an idea of what it should look like
<clever>
related somewhat, i was digging thru the pi3 boot rom earlier
<clever>
and i discovered code that assembles the usb descriptor, and changes how it does so, based on if an SD card is detected
dormito10 has joined #osdev
_xor has joined #osdev
Burgundy has joined #osdev
<clever>
so, if i connect a bcm2835 without any SD card to my usb port, i get a configuration descriptor containing 1 interface and 2 endpoints, and it is a "vendor specific" interface (rpiboot)
<GeDaMo>
Does it become a device rather than a host without an SD card?
<clever>
GeDaMo: its a device in both cases, but it gains an MSD interface
<GeDaMo>
Ah
<clever>
according to the code
<clever>
so you can then read/write the SD card over usb
<GeDaMo>
So it looks like a mass storage device
<GeDaMo>
Neat
<clever>
but the documentation makes zero mention of this ability
dormito has quit [Ping timeout: 260 seconds]
<clever>
[350894.578240] usb 4-2: config index 0 descriptor too short (expected 55, got 32)
<clever>
ah, and thats a bug i had spotted in other versions
<clever>
linux will first do a short read of 9 bytes, to get just the configuration descriptor
<clever>
which includes the total length of all descriptors (config+interface+endpoint)
<clever>
then it does a second read of the total length, to get the whole set
terminalpusher has joined #osdev
<clever>
the bootrom is patching the total length, after it has already copied the configuration descriptor to the output buffer
<clever>
so it winds up sending the unpatched header over
<clever>
so, without an SD card, i get the 32 byte descriptor, with 1 interface and 2 endpoints, as expected
<clever>
it versk!!
<clever>
i put a uSD card without bootcode.bin into the pi02, and plugged in the usb
<clever>
and boom!
<clever>
[351216.540344] usb-storage 4-2:1.0: USB Mass Storage device detected
<GeDaMo>
Why are you putting 130 and 140 in al and ah?
sonny has joined #osdev
<GeDaMo>
If you're concerned that the direction flag isn't 0, you might want to clear it before you do anything which uses it e.g. lodsb
<Ali_A>
GeDaMo
<GeDaMo>
Ali_A
<Ali_A>
I was just typing and hit enter, sorry + I just wanted to move the cursor down, I tested the code again after disabling the call to set cursor position, I think my understand of cursor is not the same as text cursor but probably the cursor that controls the screen position?
<GeDaMo>
By the way, you can replace mov dh, ah; mov dl, al with just mov dx, ax
<GeDaMo>
The cursor position be in character counts, the default screen size is 80x25 I think, with 0,0 at the top left
<Ali_A>
however, in the source code it seems to go to address to 0x1000
<Ali_A>
and not 0x7c00
<Ali_A>
+
<Ali_A>
do I assume the CPU (after the POST stage) automatically interacts with the ram and loads the boot sector (the first sector) into the ram?
<Ali_A>
otherwise, where would be the 0x7c00
<zid>
in what way do you think it doesn't load to 7C00
<zid>
there isn't even a 1000 on that page
<CompanionCube>
also there's no 'automatic' interaction
<CompanionCube>
e.g uefi systems don't load a boot sector
<zid>
looks like it.. copies itself from 7C00 to 600, then does 'find_partition' on a bunch of partition entries, and if it finds one it calls bios routine 13,42 which is some sort of extended load, using a data structure on line 93
<zid>
which makes it load a sector to 7C00 again
<Ali_A>
zid I must be blind, for some reason I have seen it 0x1000 for the past 3 days
<Ali_A>
+
<Ali_A>
thanks for the explanations!
<zid>
seen what?
<Ali_A>
[0x1000] instead of [0x600]
<zid>
org isn't even anything to do with this
<zid>
that just has to match what's on line 29 and 32
<zid>
org is an *assembler* directive for how it generates the code
<zid>
nothing to do with how the bios works
<Ali_A>
I thought orgs is were the bios is going to copy your code to after it reads the last two bytes of the first sector and finds it `bootable`
<zid>
org not orgs
<zid>
that's.. an insane leap of logic you've made there
<bslsk05>
stackoverflow.com: assembly - x86 NASM 'org' directive meaning - Stack Overflow
<geist>
yah no. org just tells the assembler to emit relative things as if it was at that point
<Ali_A>
'=D which made me think what I said above
<zid>
I see.. I guess..
<geist>
usually most folks set org to 0 in their bootloader and then set the segment regsters to 0 so code operates as if it was at 0x7c00
<geist>
the alternative is to set the segment registers to 0x7c0 and org to 0
<zid>
This is consistent with actual programs
<zid>
where you do org 100h for dos, etc
<zid>
org 7c00h is also common
<geist>
right. i guess basically you set the org to where your segment registers are set to
<zid>
I wouldn't say "most folks"
<geist>
so that offsets the assembler generates are correct
<zid>
dos you very don't, you set it to 100h because of the PSP, you're always loaded to x:0100, the org is matching the offset there
<geist>
how the segments are set up at the first instruction of your bootsector i *think* are undefined
<geist>
yah for dos i'm sure there are more complex forms of this, i'm thinking about for explicitly the purpose of writing a bootsector loader
<zid>
I'd say the exact opposite, in terms of common usage, you org for the offset
<geist>
oh yeah, i think you're right. duh.
<geist>
right right, org the offset
<geist>
still haven't finished my cofeee this morning
<zid>
and they're caring simultaneously about 0000:7C00 and 0000:0600.. there's probably a common segment you could use, 0x60 or whatever to make *one* of them a zero offset, but it'd make 7C00 look super weird
<zid>
60:0 and 060:3000 or something weird
<zid>
I'm too lazy to do actual math
<geist>
it is hard
blockhead has joined #osdev
nj0rd has quit [Quit: WeeChat 3.4]
nj0rd has joined #osdev
jeaye has joined #osdev
Payam95 has quit [Quit: Client closed]
<kingoffrance>
https://github.com/davidgiven/ack/blob/default/plat/pc86/boot.s This code makes up the PC boot sector, and is the first thing on the ! floppy disk. The PC will load this sector to 0x07C0:0000 and jump to it ! with dl set to our drive, but it won't necessarily do it in a sane way ! (some BIOSes jump to 0x0000:7C00 instead). So, we need to fix that. jmpf BOOT_SEGMENT : start2 <- no comment
<bslsk05>
github.com: ack/boot.s at default · davidgiven/ack · GitHub
k8yun has quit [Quit: Leaving]
dormito has quit [Ping timeout: 245 seconds]
sonny has joined #osdev
<geist>
yahi think the safe thing to do is immediately reload your segment registers to get to a sane setup
<geist>
and i think yo ucan do it a teensy bit smaller i fyou set them to zero, since you can xor ax, ax
GeDaMo has quit [Remote host closed the connection]
mahmutov has quit [Ping timeout: 268 seconds]
jeaye has quit [Quit: WeeChat 3.3]
srjek has joined #osdev
jeaye has joined #osdev
jeaye has quit [Client Quit]
mahmutov has joined #osdev
sonny has quit [Quit: Ping timeout (120 seconds)]
jeaye has joined #osdev
sonny has joined #osdev
sonny has quit [Client Quit]
jeaye has quit [Client Quit]
jeaye has joined #osdev
sonny has joined #osdev
<sonny>
ok, so for the billionth time ... is the mmu a design that won out or would it happen eventually? (I'm thinking about what osdev looks like on a small arm device and comparing it with amd64)
<j`ey>
would what happen eventually?
<sonny>
an mmu becoming a required component in os implementation and design
<j`ey>
it's not required, small OSs like RTOS etc wont require it
<sonny>
in a small OS wouldn't all the memory go to the app? you can just have app memory start lower than the OS kernel memory or something
<zid>
It's a natural progression from 'wanting to run multiple arbitrary antagononistic programs'
<sonny>
antagonistic haha
<sonny>
ok
<zid>
aka you have an admin process and a user process
<sonny>
thanks, that makes sense
<sonny>
unless someone invented a different way to address stuff in memory
<zid>
if programs were all trusted you wouldn't need that distinction
<zid>
and they could all live in the same address space by "promising not to look at your password"
<sonny>
lol
<zid>
instead of you having to use the cpu to enforce it
<sonny>
ok great
<sonny>
it makes sense now
<sonny>
you could also physically partition the memory, but that's probably impratical
immibis has joined #osdev
<j`ey>
how?
<j`ey>
by compiling the code specifically?
<sonny>
in hardware
<zid>
that's what an mmu does
<zid>
it's a piece of hardware that partitions memory
<CompanionCube>
zid: the other way of doing it is to ensure it cannot happen by requiring all code be generated by a trusted compiler that enforces security restrictions
<zid>
CompanionCube: yea, or just only running javascript and hoping for no bugs in the runtime
<immibis>
another possibility is to give up on process isolation
<j`ey>
there's als MPU, which can set some basic memory protections, but cant partition as well as an mmu
<CompanionCube>
zid: i mean that's the same thing no?
<immibis>
you can have an OS without process isolation. Just gotta give up a whole lot of security guarantees, a la Windows 95
<zid>
CompanionCube: not.. exactly? very similar though
<immibis>
but it's still an OS
<zid>
you don't need a "trusted" anything, promising not to be naughty in the javascript case
<zid>
it's just.. not possible because there's no primitive that would let you in the language
mahmutov has quit [Ping timeout: 256 seconds]
<CompanionCube>
i would describe v8's jit or whateveras 'trusted' in this setup
<zid>
if it's inside the kernel it isn't really "trusted" as just "the semantics of the OS" at that point though
<zid>
rather than an external build providing binaries it says are fine, the kernel can just ONLY run 'fine' code.
<CompanionCube>
yes that's how it usually works
<zid>
non-fine code doesn't have a way to exist
<zid>
kernel only knows how to run js, js has no primitive to snoop the password
<zid>
security through.. defualtery? :p
<immibis>
security through piles of performance hacks that are not formally verified and now run in kernel mode
<immibis>
and even if they are formally verified it's no good because your processor is cheating on you
<sonny>
lmao
<immibis>
doesn't just about every single javascript engine bug (and CPU bug) exploit an unexpected edge case in an optimization?
<zid>
[21:50] <zid> CompanionCube: yea, or just only running javascript and hoping for no bugs in the runtime
<zid>
the second part there is doing a lot of work in those security models
<sonny>
how wound an OS take advantage of the Harvard architecture?
<zid>
are we answering your coursework
<immibis>
what does "take advantage" mean here?
<mrvn>
sonny: what Harvard architecture?
<sonny>
zid not in school (yet)
<immibis>
you can have an OS in a harvard architecture, but you have to compile all the programs and the OS into one big package
<sonny>
oh
<immibis>
because you can't load programs from disk... unless they're javascript
<immibis>
(or any other interpreted language)
<immibis>
(because interpreted code is data, as far as the CPU is concerned)
<mrvn>
Arduino comes to mind there
<immibis>
the apollo guidance computer was a harvard architecture with an OS
<immibis>
and it got to the moon
<mrvn>
immibis: accidentally basically
<CompanionCube>
the snarky response would involve pointing at modern CPUs of the 'modified harvard' type :p
<sonny>
they didn't have security woes did they?
<immibis>
well no. nobody could hack the apollo guidance computer
<immibis>
it wasn't connected to the internet
<mrvn>
The apollo guidance computer use recursive interrupts without a guard to prevent one interrupting itself.
<zid>
that's the "no antagonostic code" part
<mrvn>
verry bad OS design there.
<zid>
It only caused one bug it's fine
<immibis>
mrvn: they did a careful design analysis, something we do not do today because we are lazy and entitled
<immibis>
they planned out how much work the computer would have
<immibis>
but they made a mistake
<zid>
what was the error, 77 or something? i forget
<immibis>
in fact, since the computer automatically dropped low-priority tasks when overloaded, that's an example of an OS working *well*
<mrvn>
immibis: that wasn't what saved it.
<immibis>
as opposed to my computer, which happily pages firefox and hexchat and xmonad out of memory in order to run another compiler process
<mrvn>
The OS was persistant so every time it crashed it just picked up from the last save state.
<immibis>
if sonny wants to talk about accidents - volatile memory is an acident
<mrvn>
So every time the stack overflowed during landing it recovered.
<sonny>
unreal
<immibis>
early computers did not clear RAM when turned off
<immibis>
well actually, some did and some didn't
<mrvn>
immibis: modern computers don't either.
<immibis>
mrvn: if you want to be pedantic, early RAM did not require power to not forget its data
<mrvn>
immibis: core memory? The charge drains away over time.
<immibis>
core memory doesn't have leakage. you're thinking of DRAM, which is still used toda
<immibis>
y
<mrvn>
The magnetic field still decays over time, like harddisks.
<mrvn>
not so much leakage but bit flips
JanC has quit [Read error: Connection reset by peer]
JanC has joined #osdev
janemba has joined #osdev
<immibis>
sonny: what is an operating system?
<sonny>
it's the executive process that manages other programs
<sonny>
it requires an abstraction for hardware in order to work
<sonny>
s/for/of/
<sonny>
nailed it :-)
<immibis>
sonny: yeah so anything that does that counts as an operating system
<immibis>
like the system on the apollo computer that just prioritized the most urgent stuff to work on, and handled the keyboard and screen - that could be called an operating system
dormito has joined #osdev
<sonny>
it didn't delegate, but yeah
<sonny>
or it sounds like it did not
<immibis>
i'm not sure it needs to abstract hardware
<sonny>
yes, that is required
<mrvn>
You had tasks and could start/stop them
<sonny>
mrvn when you start one it saves the others to disk?
<mrvn>
sonny: what disk? It loads them from rom
<sonny>
ohh
<sonny>
ancient
<mrvn>
I don't think it had any persistant storage other than not reseting the ram on reset.
<immibis>
there is room for people to disagree though
<immibis>
it's not terribly important
<sonny>
immibis doesn't the microkernel just delegate to servers?
<mrvn>
sonny: isn't evey driver in your kernel a "server"?
<immibis>
yes but those aren't part of the kernel
<sonny>
immibis defining it has been tremendously helpful for me actually
<immibis>
then again, it's called a microKERNEL, not a microOS
<immibis>
so maybe it doesn't count
<sonny>
good point
<mrvn>
I think the kernel was baked into the hardware in the apollo guidance computer
<sonny>
not a bad idea
<mrvn>
The CPU is bascially just running interrupt handlers
<mrvn>
It didn't switch tasks but just recursed into the next app and hoped they would return in time so the stack didn't overflow.
<sonny>
I've figured out what to use in my os language for dynamic resources, linear logic or ref counting seems pretty good
<sonny>
mrvn: but they already calculated it would not?
<mrvn>
if only c++ could simulate linear types
<immibis>
some of the tasks ended up running more often than calculated
<immibis>
because of a bug in one of the sensors that caused it to interrupt more often
<sonny>
this is a great story, I'm gonna read about it
<mrvn>
sonny: No, they just tested and hoped. Then on the moon landing one of the radars had a fault and kept interrupting way more than it should causing the load to go >100% and stack overflow happened.
<sonny>
damnnn
<sonny>
but it restarted somehow?
<immibis>
you don't test and hope on a moon mission
<sonny>
yeah, I would hope not
<mrvn>
yes. it resets and doesn't restart minor tasks (like the output display) automatically. Without the extra load it was <100% till late in the landing.
<mrvn>
sonny: the memory is persistant with apps saving a "good" state whenever they have one so after reset they can just pick right up with only minor loss. Usually.
<mrvn>
That part was rather genius.
<mrvn>
They really designed it for things to go wrong and recover. So the bad design of not catching interrupts recursing on themself wasn't fatal.
<mrvn>
sonny: there are some verry good videos about it. Making a hard realtime system is really hard. If your workload is greater than your computational capacity there really isn't anything you can do but fails something.
<mrvn>
I'm really just complaining they didn't have a check for it and show a proper error message.
<mrvn>
or dynamically skip low prio stuff, update the display only half as often for example.
pretty_dumm_guy has quit [Quit: WeeChat 3.4.1]
bgs has quit [Remote host closed the connection]
<sonny>
mrvn thanks, that restart stuff is super genius
Ali_A has quit [Quit: Connection closed]
bgs has joined #osdev
<sonny>
I wonder how long before that made it to other OSes
<mrvn>
there are some more modern kernels with persistance property. But with network traffic that gets really bad to handle.
<mrvn>
do you wait for the harddisk to save a page before you send out an ACK for TCP?
<sonny>
oh really? you'd think they could add another message for pause resume
<sonny>
yes?
<mrvn>
try that with GBit.
<mrvn>
Maybe with non-volatile memory you could do it again.
<sonny>
just send, I'm busy signal other side can wait or save state
<mrvn>
sonny: that's not how TCP works.
<sonny>
who said it had to be TCP? :P
<mrvn>
sonny: if you only want networking with other systems running your OS then sure. I was talking having it in the internet.
<sonny>
ohhh
<mrvn>
Open your webbrowser and start wathing a video. Turn it of, turn it on and it just resumes playing without amazon even noticing you rebooted.
<immibis>
more realistically there are operating systems where you roll back some seconds when the power turns off
<immibis>
using continuous checkpointing, or whatever it's actually called
<immibis>
only research operating systems, not anything anyone actually uses. It probably is slo
<immibis>
w
<mrvn>
yeah, you can't checkoint every ethernet frame so you only do it every second or so. But then all network connections have to reset and replay.
<mrvn>
With non-volatile memory you could do the checkpointing with the MMU, set a COW flag 1/1000th of a second and keep 2 or 3 states in memory.
<mrvn>
+every
<mrvn>
.oO(Wenn will cheap ARM boards have non-volatile memory? *dream*)
<mrvn>
clever: Does the RPi train the DRAM controller on boot in a destructive way or could you add a large capacitor to the DRAM to make it non-volatile?
<clever>
mrvn: destructive way?
<mrvn>
overwrite the contents with test patterns
<clever>
ah, no idea
<clever>
i dont know how the training works on the pi4
<clever>
for earlier models, i suspect it is non-destructive, and its far simpler
<clever>
to make things non-volatile, you need to do 2 things