xv6

What does the declaration“extern struct cpu *cpu asm(“%gs:0”);” mean?

ぃ、小莉子 提交于 2019-11-29 07:12:43
When I'm reading the xv6 source code, I'm confused about the syntax of the declaration below. Can anyone explain it to me? extern struct cpu *cpu asm("%gs:0"); David Wohlferd I assume you understand what extern struct cpu *cpu means. The question you have is: What does the asm("%gs:0") part mean? This code is using a gcc extension called asm labels to say that the variable cpu is defined by the assembler string %gs:0 . This is NOT how this extension is intended to be used and is considered a hack . There's an excellent discussion of gs (and fs) here , but in short gs points to the current

how do i add a system call / utility in xv6

筅森魡賤 提交于 2019-11-26 19:46:41
问题 Can any one tell me/ point me any references to how to add a system call / utility in XV6 exhaustive search on google was futile and hacking the hard way also was not productive so far . the reference book also did not have any hello world example to start with any help greatly appreciated 回答1: Read this: http://zoo.cs.yale.edu/classes/cs422/2010/xv6-book/trap.pdf It explains it quite well 回答2: To add a system call that can be called in xv6's shell, you should so something with the five files