Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
Shinpei Kato
Shinpei Kato committed Sep 3, 2012
2 parents cd53c55 + 5d0d546 commit ad91a08203e24727c757c7d48b48b5e02409ae9f
Showing with 3,682 additions and 9 deletions.
  1. +12 −9 cuda/driver_api/gdev_cuda.c
  2. +73 −0 fw/fermi/Makefile
  3. +29 −0 fw/fermi/asminsn.h
  4. +71 −0 fw/fermi/boot.S
  5. +1,141 −0 fw/fermi/gpc.c
  6. +2,059 −0 fw/fermi/hub.c
  7. +54 −0 fw/fermi/mmio.h
  8. +122 −0 fw/fermi/regs_gpc.h
  9. +116 −0 fw/fermi/regs_hub.h
  10. +5 −0 fw/fermi/types.h
@@ -116,19 +116,20 @@ static void unload_bin(char *bin, file_t *fp)
static void cubin_func_skip(char **pos, section_entry_t *e)
{
*pos += sizeof(section_entry_t);
+ printf("/* nv.info: ignore entry type: 0x%04x, size=0x%x */\n",
+ e->type, e->size);
//#define GDEV_DEBUG
#ifdef GDEV_DEBUG
#ifndef __KERNEL__
- int i;
- printf("/* nv.info: ignore entry type: 0x%04x, size=0x%x */\n",
- e->type, e->size);
if (e->size % 4 == 0) {
+ int i;
for (i = 0; i < e->size / 4; i++) {
uint32_t val = ((uint32_t*)*pos)[i];
printf("0x%04x\n", val);
}
}
else {
+ int i;
for (i = 0; i < e->size; i++) {
unsigned char val = ((unsigned char*)*pos)[i];
printf("0x%02x\n", (uint32_t)val);
@@ -269,24 +270,24 @@ static int cubin_func_type
return cubin_func_1903(pos, e, raw_func);
case 0x1704: /* each parameter information */
return cubin_func_1704(pos, e, raw_func);
- case 0x0001: /* unknown */
+ case 0x0001: /* ??? */
cubin_func_skip(pos, e);
break;
- case 0x080d: /* unknown */
+ case 0x080d: /* ??? */
cubin_func_skip(pos, e);
break;
case 0xf000: /* maybe just padding??? */
*pos += 4;
break;
- case 0xffff: /* unknown */
+ case 0xffff: /* ??? */
cubin_func_skip(pos, e);
break;
- case 0x0020: /* unknown */
+ case 0x0020: /* ??? */
cubin_func_skip(pos, e);
break;
default: /* real unknown */
cubin_func_unknown(pos, e);
- return -EINVAL;
+ /* return -EINVAL; */
}
return 0;
@@ -594,6 +595,8 @@ CUresult gdev_cuda_load_cubin(struct CUmod_st *mod, const char *fname)
switch (sym->st_info) {
case 0x0: /* ??? */
break;
+ case 0x2: /* ??? */
+ break;
case 0x3: /* ??? */
break;
case 0x11: /* __device__/__constant__ symbols */
@@ -643,7 +646,7 @@ CUresult gdev_cuda_load_cubin(struct CUmod_st *mod, const char *fname)
break;
default:
cubin_func_unknown(&pos, e);
- goto fail_function;
+ /* goto fail_function; */
}
}
View
@@ -0,0 +1,73 @@
+# TARGET NAME
+TARGET = hub_firmware
+TARGET1a = gpc_firmware
+
+# COMPILER
+CLANG = clang
+CLANG_FLAGS = -m32 -emit-llvm -S -O1
+ENVYAS = envyas
+ENVYAS_FLAGS = -m fuc -V fuc3
+LLC = llc
+LLC_FLAGS = -march=nvfc
+
+# DIR
+NVFC_ROOT = ../../../nvfc
+SCRIPT_DIR = $(NVFC_ROOT)/script
+GDEV_PSCNV_DIR = ../../mod/pscnv/
+
+# SCRIPT
+LLVM2ENVYAS = $(SCRIPT_DIR)/llvm2envyas
+HEX2BIN = $(SCRIPT_DIR)/hex2bin
+HEX2BYTELIST = $(SCRIPT_DIR)/hex2bytelist
+BIN2CTXCTLH = $(SCRIPT_DIR)/datalist
+
+# LOADER
+LOADER = $(NVFC_ROOT)/loader_firmware/fucload
+CAT = cat
+OPT = opt
+
+all:
+ make 09
+ make 1a
+
+
+09: hub.c
+ $(CLANG) $< -o $(TARGET).bc $(CLANG_FLAGS)
+ $(LLC) $(TARGET).bc -o $(TARGET).s $(LLC_FLAGS)
+ $(LLVM2ENVYAS) $(TARGET).s -c $(TARGET).tmp -d $(TARGET).data.S
+ $(CAT) boot.S $(TARGET).tmp > $(TARGET).S
+
+1a: gpc.c
+ $(CLANG) $< -o $(TARGET1a).bc $(CLANG_FLAGS)
+ $(LLC) $(TARGET1a).bc -o $(TARGET1a).s $(LLC_FLAGS)
+ $(LLVM2ENVYAS) $(TARGET1a).s -c $(TARGET1a).tmp -d $(TARGET1a).data.S
+ $(CAT) boot.S $(TARGET1a).tmp > $(TARGET1a).S
+
+clean:
+ rm -f $(TARGET).* $(TARGET1a).* hub_ctxctl.h.data gpc_ctxctl.h.data nvc0_ctxctl.h* *~
+
+h:
+ $(ENVYAS) $(TARGET).S $(ENVYAS_FLAGS) > $(TARGET).bytelist
+ $(ENVYAS) $(TARGET1a).S $(ENVYAS_FLAGS) > $(TARGET1a).bytelist
+ $(HEX2BYTELIST) $(TARGET).data.S $(TARGET).data.bytelist
+ $(HEX2BYTELIST) $(TARGET1a).data.S $(TARGET1a).data.bytelist
+ $(BIN2CTXCTLH) $(TARGET).data.bytelist $(TARGET).bytelist -m hub
+ $(BIN2CTXCTLH) $(TARGET1a).data.bytelist $(TARGET1a).bytelist -m gpc
+ echo > nvc0_ctxctl.h
+ $(CAT) nvc0_ctxctl.h.hub >> nvc0_ctxctl.h
+ $(CAT) nvc0_ctxctl.h.gpc >> nvc0_ctxctl.h
+ make install
+
+install :
+ cp nvc0_ctxctl.h $(GDEV_PSCNV_DIR)
+
+run:
+ $(ENVYAS) -i $(TARGET).S $(ENVYAS_FLAGS) > $(TARGET).bin
+ $(ENVYAS) -i $(TARGET1a).S $(ENVYAS_FLAGS) > $(TARGET1a).bin
+ $(HEX2BIN) $(TARGET).data.S $(TARGET).data.bin
+ $(HEX2BIN) $(TARGET1a).data.S $(TARGET1a).data.bin
+ sudo $(LOADER) -09c $(TARGET).bin -09d $(TARGET).data.bin -1ac $(TARGET1a).bin -1ad $(TARGET1a).data.bin
+
+#install:
+# cp $(TARGET).bin /lib/firmware/nouveau/fuc409c
+# cp $(TARGET).data.bin /lib/firmware/nouveau/fuc409d
View
@@ -0,0 +1,29 @@
+#ifndef __ASMINSN_H__
+#define __ASMINSN_H__
+
+/* sleep until interrupt */
+#define sleep(b) __asm__ volatile("sleep "#b)
+/* set bit in the $flags register */
+#define set_flags(b) __asm__ volatile("bset\t$flags "#b)
+/* clear bit in the $flags register */
+#define clr_flags(b) __asm__ volatile("bclr\t$flags "#b)
+
+#define set_xdbase(x) __asm__ volatile("mov\t$xdbase %0" :: "r"(x))
+#define set_xtargets(x) __asm__ volatile("mov\t$xtargets %0" :: "r"(x))
+
+#define xdld(offset, size_addr) \
+ __asm__ volatile("xdld\t%0 %1" :: "r"(offset), "r"(size_addr))
+
+#define xdst(offset, size_addr) \
+ __asm__ volatile("xdst\t%0 %1" :: "r"(offset), "r"(size_addr))
+
+#define xdwait() \
+ __asm__ volatile("xdwait");
+
+#define extrs(dst, src, a, b) \
+ __asm__ volatile("extrs\t%0 %1 "#a":"#b : "=r"(dst): "r"(x))
+
+#define extr(dst, src, a, b) \
+ __asm__ volatile("extr\t%0 %1 "#a":"#b : "=r"(dst): "r"(src))
+
+#endif
View
@@ -0,0 +1,71 @@
+//////////////////////////////////////////
+// Bootstrap code
+//////////////////////////////////////////
+// 0x00
+
+boot:
+ // set stack pointer
+ mov $r0 0x1000
+ sethi $r0 0
+ mov $sp $r0
+ // set interrupt vector
+// mov $r0 0x1b // interrupt handler (hardcoded)
+ mov $r0 #ih // interrupt handler (hardcoded)
+ sethi $r0 0x0
+ mov $iv0 $r0
+ clear b32 $r0
+ // jump to the main function
+ call #main
+ // exit the program
+ exit
+// 0x1b
+ih:
+
+//mov $r10 $flags
+//call #ihbody
+//mov $flags $r10
+
+ push $r0
+ push $r1
+ push $r2
+ push $r3
+ push $r4
+ push $r5
+ push $r6
+ push $r7
+ push $r8
+ push $r9
+ push $r10
+ push $r11
+ push $r12
+ push $r13
+ push $r14
+ push $r15
+ mov $r10 $flags
+ push $r10
+ call #ihbody
+ pop $r10
+ mov $flags $r10
+ pop $r15
+ pop $r14
+ pop $r13
+ pop $r12
+ pop $r11
+ pop $r10
+ pop $r9
+ pop $r8
+ pop $r7
+ pop $r6
+ pop $r5
+ pop $r4
+ pop $r3
+ pop $r2
+ pop $r1
+ pop $r0
+ bset $flags $p2
+ iret
+
+//////////////////////////////////////////
+// User code
+///////////////////////////////////////////
+
Oops, something went wrong.

0 comments on commit ad91a08

Please sign in to comment.