感觉这才是值得做的编程工作啊!吾辈当自勉

277 天前
 levelworm

https://news.ycombinator.com/item?id=42465378

Xbox 360 的一位软件工作者也来发了个帖子:

One challenge was that while I started working on the Xbox 360 about three years before it would ship, we knew that the custom CPU would not be available until early 2005 (first chips arrived in early February). And there was only supposed to be one hardware spin before final release.

一项挑战是,我是在 XBox 360 发售三年前开始给它写代码的(这位程序员当时写的是 bootloader 、kernel 和 hypervisor )。我们知道要等到 2005 年年初才能拿到芯片。

So I had no real hardware to test any of the software I was writing, and no other chips (like the Apple G5 we used as alpha kits) had the custom security hardware or boot sequence like the custom chip would have. But I still needed to provide the first stage boot loader which is stored in ROM inside the CPU weeks before first manufacture.

但是我仍然需要在开始生产之前数周的时候就拿出 bootloader 的代码,用以在生产之时保存在 ROM 中。

I ended up writing a simulator of the CPU (instruction level), to make progress on writing the boot code. Obviously my boot code and hypervisor would run perfectly on my simulator since I wrote both!

于是我最后写了一个指令级的 CPU 模拟器,用来帮助我的编程工作。我的 bootloader 和 hypervisor 在模拟器上运行的很完美。

But IBM had also had a hardware accelerated cycle-accurate simulator that I got to use. I was required to boot the entire Xbox 360 kernel in their simulator before I could release the boot ROM. What takes a few seconds on hardware to boot took over 3 hours in simulation. The POST codes would be displayed every so often to let me know that progress was still being made.

IBM 也提供了一个硬件加速的、能够精准到时钟周期的模拟器。我需要在烧录 ROM 之前在这个模拟器上成功运行整个 XBox 360 的 kernel 。在硬件上只需要几秒钟就能开机,但是在 IBM 提供的模拟器上却需要三个小时才能完成整个开机过程。为了显示开机程序还在运行,自检代码每隔一会就会在屏幕上出现。

The first CPU arrived on a Friday, by Saturday the electrical engineers flew to Austin to help get the chip on the motherboard and make sure FSB and other busses were all working. I arrived on Monday evening with a laptop containing the source code to the kernel, on Tuesday I compiled and flashed various versions, working through the typical bring-up issues. By Wednesday afternoon the kernel was running Quake, including sound output and controller input.

第一块 CPU 周五运到。周六硬件工程师飞到 Austin 去帮助把它安装在主板上,并保证总线正常工作。我是周一晚上赶到的,随身带了一台笔记本电脑,上面有 kernel 的代码。到了周二,代码编译好并烧录进机器,到了周三下午就能够跑 Quake 了,包括声音输出和摇杆输入。

Three years of preparation to make my contribution to hardware bring-up as short as possible, since I would bottleneck everyone else in the development team until the CPU booted the kernel.


关于这位大牛自己写的模拟器(指令级别)的一些趣闻:

I called the simulator Sbox and it was just a simple console app. I didn't implement the GPU, so no graphics just the hypervisor and kernel and some simple non-graphics apps. I made it so that you could build the Xbox 360 kernel on your windows machine, then just run sbox.exe and it would automatically find the just built kernel image targeting the PPC64 and boot it. Then if you typed control-C it would drop into the kernel debugger as a sub process, and you could poke around at the machine state as if it were the real Xbox hardware, showing all the PPC instructions and registers. It was a lot of fun writing it, and quite useful.

我把它叫做 Sbox 。它不模拟 GPU ,所以没有图像,只有 hypervisor 和 kernel 以及一些简单的文字程序。开发团队能够在 Windows 上编译 Xbox 360 内核,然后运行 sbox.exe ,它就能自动找到刚刚编译好的针对 Power PC 的内核二进制文件,并在模拟器内部开机。如果你输入 Ctrl-C ,那么就能进入到 kernel debugger 的子进程,勘察(模拟)机器的状态,包括所有 Power PC 指令和计算器,就好像这是一台真正的 XBox 360 一样。

(以下是大牛的一位同事说的)

You should also talk about the lwarx/stecx bug. IIRC - in the first version of the chip there was a bug in one or both of these instructions. Your code booted on SBox but didn't on the hardware. You compared the two and then figured out it was these instructions. You filed a bug report and then dug into them and used SBox to figure out what must have been going wrong.

你应该谈谈 lwarx/stecx bug 。我没记错的话,第一版的芯片有这个 bug 。你的代码能够在 Sbox 上运行,但是不能在硬件上运行。你在对比了两者之后,分析出是这两个指令的问题。你(给 IBM )递交了一份 bug 报告。

The chip supplier came back with a workaround and within five minutes you simulated it on SBox and said it wouldn't work, why, and then said how it should be fixed.

IBM 送了一块新的芯片过来,你在 SBox 上跑了五分钟之后就说它肯定不行,应该怎么样怎么样才能解决这个问题。(我读下来的感觉是,IBM 仅仅是提供了一个 workaround ,然后大牛在 SBox 里模拟了这个 workaround ,发现还是不行)

The supplier didn't believe you as yet. And you worked out a workaround so we could be unblocked. Two weeks later they agreed with your fix...

IBM 不相信你的话,于是你自己想了个解决办法,避免我们的进度停滞不前。两个礼拜之后 IBM 说你的解决办法没错。

9677 次点击
所在节点    程序员
58 条回复
levelworm
275 天前
@drymonfidelia #40
这个我觉得也是事实,但是总归有人希望在技术上精进的。虽然就钱途来说,横向发展可能更好。
Rat3
274 天前
@drymonfidelia

可惜什么?不是只会写 crud ,是市场上只需要 CRUD 罢了,有没有必要在这一副怨天尤人的姿态啊,谁拦着你去微软写底层了吗?
name1991
274 天前
公司里做技术的话语权太少了,PM 催进度的话你能说啥?需要花时间做的 improment 你怎么说服你的老板?都是问题。。。
levelworm
274 天前
@name1991 #43
今天又看到一个类似的例子,在苹果写 Rosetta 2 的大牛(前期完全是一个人写的)。滑铁卢数学硕士毕业,直接进苹果就开始做底层( WebKit 解释器)。正好是 2009 年进去,经历了 iPhone, iPad 和 Apple Silicone 的前期开发。

我感觉这就是个人和学校的威力叠加。
levelworm
274 天前
name1991
274 天前
@levelworm #45 类似这种一个人做的某某东西感觉需要一个比较宽松的公司环境。个人能力肯定是必须的,不然无从谈起,但是如果你所在的部门是那种天天赶火线的,feature 压力和 deadline 压力都很大的部门,根本就无从谈起了。我个人感觉在公司遇到的或者是听到的这种牛人也都是在部门压力没那么大,然后部门领导也不是那么喜欢卷人的环境。个人能力+公司氛围感觉缺一不可吧。
drymonfidelia
274 天前
@Meld 了解底层肯定对 CRUD 有帮助,公司的 CRUD 系统老是内存泄露,用不停自动重启一次扛了几年,我在 V 站发了七八个帖子找大佬帮忙看看什么原因,一直没解决。最后实在扛不住了,一直重启对业务造成影响了,花了几万请专家看,是一个依赖的 bug
Shazoo
274 天前
这种大神我见过一位……

嫌弃 vc 实现底层的模拟器不爽( ui 级代码调试),自己 freebsd 下实现了个 arm7tdmi 的模拟器……

当时工具链都是 ads1.2……

……

没错,我就是做那个 vc 模拟器的……脸肿了好久
levelworm
274 天前
@name1991 #46
感觉的确如此。我估计华为应该是有这个氛围的吧。
levelworm
274 天前
@Shazoo #48
别谦虚了,你也是大牛,哈哈
levelworm
274 天前
@drymonfidelia #47
这个倒是,不过估计这种机会不多。。。
nevermoreluo
273 天前
@majula #14
emmmm 还真遇到过这种奇怪的需求,文档很久之前对方给过,但是人员变更没保留下来,后来成竞争对手了。。。
这种三方给外部调用的动态,在不加密的情况下还是可以搞的。。。
动态库暴露给外部的接口名可以拿 depends 解析出来,参数可以拿 IDA 推出来,现在有 ai 了结合一下都不用看得懂 IDA 的伪代码,直接扔给 ai 能给个八九不离十的结果了
当然这才是第一步,如果对方的库里面有些奇怪的 bug ,比如设置某个设置后需要读取一次才能保存成功之类的。。。才是噩梦的开始
48y1951r9G8k7Zou
273 天前
@nevermoreluo #52

我们是因为甲方那边的文档都在代码注释里面,而代码是他们从另外一家公司买的,按照合同他们在 10 年内不能泄露源码,所以没法给我们看。并不是故意为难

最后是从隔壁部门找了个懂逆向的大佬解决的。他花了两天时间整理出来一个 .h 文件,里面有 50 多个函数和它们的参数、返回值、功能说明。按照他的说法其实有好几百个函数,但是剩下的我们用不到

那个时候别说 ChatGPT 了,GPT-1 还没出来呢。换作我就是不可能的任务,两天时间估计一个函数都弄不明白
roidinev
271 天前
v2 上多分享些这些
1Z3KYa0qBLvei98o
260 天前
@name1991 是的, 比如很多上市公司.
1Z3KYa0qBLvei98o
260 天前
@levelworm Java / go(腾讯) / Web 不都是这样. 不是有一个梗, 需要 985 的才能写出不会内存泄露/崩溃的程序. 我现在的 app, 已经把动态内存分配给禁止了, 结果接我活的小姑娘动不动就 crash. 反正我当初的想法就是, 要是 crash 就早点 crash.
levelworm
260 天前
@VchentozV #56
我现在的想法就是努力自学,和你们这种大佬一块喝咖啡。
levelworm
260 天前
@VchentozV #56
我感觉好学校好专业的出去的确不一样,哪怕之前不是 CS 专业的,招进去照样代码写的很好。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1098992

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX