Skip to content

Instantly share code, notes, and snippets.

View gucchan22's full-sized avatar

GUCCHAN gucchan22

  • Japan
View GitHub Profile
#-*- coding:utf-8 -*-
require "pasori"
def getStudentNo(pasori)
begin
sleep(2)
timeout(5, ReadTimeout) do
pasori.felica_polling(-31279) {|felica|
felica_area = felica.service[9]
stNo = felica.read(felica_area, 1, 0)[0..7]
@gucchan22
gucchan22 / mbuf.c
Last active January 15, 2016 06:00
struct m_hdr {
struct mbuf *mb_next;
struct mbuf *mb_nextpkt;
int mh_len;
caddr_t mh_data;
short mh_type;
short mh_flags;
};
struct pkthdr { int len; struct ifnet *rcvif; }
struct m_ext {
#include "types.h"
#include "fcntl.h"
#include "user.h"
#include "fs.h"
#include "param.h"
#include "mmu.h"
#include "stat.h"
// MAC and IP addresses.
uchar hw_addr[6] = { 0xfc, 0xe9, 0xd3, 0xf6, 0xcd, 0xf8 };
#include "types.h"
#include "fcntl.h"
#include "user.h"
#include "fs.h"
#include "param.h"
#include "mmu.h"
#include "stat.h"
#define stdout 1
#define ETHER_ADDR_LEN 6
@gucchan22
gucchan22 / t.c
Last active December 19, 2015 12:48
#define ETH_MAJOR 2 // Ethernet dev-major no.
struct devsw {
int (*read)(struct inode *, char *, int);
int (*write)(struct inode *, char *, int);
};
extern struct devsw devsw[];
unsigned short eth_base = 0xc000;
devsw[ETH_MAJOR].read = ne2k_pio_read;
void ne2k_rdma_conf(uint16_t start, uint16_t bc);
void ne2k_send(uint8_t *pkt, uint16_t len) {
int i;
len = len < 0x40 ? 0x40 : len;
if((CR & TXP) != TXP) {
ne2k_rdma_conf((0x00 | (TXSTART << 8)), (len & 0xff | (len >> 8)));
CR |= (CR_PAGE0 | START | DMA_ENABLE);
for(i=0; i < len; i++) ISA_write(RDMA, pkt[i]);
CR |= (CR_PAGE0 | START | TXP);
}
@gucchan22
gucchan22 / aa.c
Last active December 16, 2015 02:28
#define TXP 0x04 // is it sending?
void ne2k_rdma_write_configure(uint16_t start, uint16_t bc);
void ne2k_rdma_write(uint8_t pkt, uint16_t len);
void send_pkt(uint8_t *pkt, uint16_t len) {
len = len < 0x40 ? 0x40 : len;
if((CR & TXP) != TXP) {
ne2k_rdma_write_configure((0x00 | (TXSTART << 8)), (len & 0xff | (len >> 8)));
CR |= (CR_PAGE0 | START | DMA_ENABLE);
ne2k_rdma_write(pkt[i], len);
CR |= (CR_PAGE0 | START | TXP);
HDDの読み書き:
ディスク番号、トラック番号、セクタ番号を指定してI/O命令を発行、HDDは指定のトラックにヘッドを動かして指定のセクタが回ってくるのを待つ
=> 磁気でデータを読み取りして、HDDは割り込みによってCPUに通知を行う
- HDDの性質としてランダムアクセスが低速で、反対にシーケンシャルアクセスが高速
ファイルシステム:
- 二次記憶装置を使いやすくするためのOSの機能
- ハードウェアの構成を隠蔽してファイル集合として仮想化
- ファイルの保護、管理、ファイル名、ファイルパスによるデータアクセス
--- Makefile 2015-12-08 07:12:58.000000000 +0900
+++ makefile_edited 2015-12-10 10:57:22.000000000 +0900
@@ -22,7 +22,7 @@
all: $(PROGRAM)
$(PROGRAM): % : %.o $(OBJECTS)
- $(CC) $(CFLAGS) -o $@ $< $(OBJECTS) $(LDFLAGS)
+ $(CC) -o $@ $< $(OBJECTS) $(CFLAGS) $(LDFLAGS)
.c.o:
- スタック
- ssレジスタが指し示しているセグメント領域でCPUが自動的にスタック命令で参照する
- フラットメモリも出るの時はリニアアドレス空間にスタックを設定でkる
- esp, ebpを仕様
- 基本的に高位アドレスから低位アドレスに成長していく
- esp: スタックの要素が今積まれている一番高いアドレス
- ebp:
- ローカル変数へのアクセス: 減算
- 関数の引数へのアクセス: 加算