24.01.2014 Views

Codice

Codice

Codice

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

196 volume VI os16<br />

Script e sorgenti del kernel 197<br />

350018 | }<br />

350019 |<br />

350020 | k_printf ("%2i %2i %2i %04x %4i %4i %4i %02i.%02i %c %05lx %04x ",<br />

350021 | (unsigned int) ps->ppid,<br />

350022 | (unsigned int) pid,<br />

350023 | (unsigned int) ps->pgrp,<br />

350024 | (unsigned int) ps->device_tty,<br />

350025 | (unsigned int) ps->uid,<br />

350026 | (unsigned int) ps->euid,<br />

350027 | (unsigned int) ps->suid,<br />

350028 | (unsigned int) ((ps->usage / CLOCKS_PER_SEC) / 60),<br />

350029 | (unsigned int) ((ps->usage / CLOCKS_PER_SEC) % 60),<br />

350030 | stat,<br />

350031 | (unsigned long int) ps->address_i,<br />

350032 | (unsigned int) ps->size_i);<br />

350033 |<br />

350034 | k_printf ("%05lx %04x %04x %s",<br />

350035 | (unsigned long int) ps->address_d,<br />

350036 | (unsigned int) ps->size_d,<br />

350037 | (unsigned int) ps->sp,<br />

350038 | ps->name);<br />

350039 |<br />

350040 | k_printf ("\n");<br />

350041 |}<br />

104.3.26 kernel/diag/print_segments.c<br />

104.3.30 kernel/diag/reverse_16_bit.c<br />

Si veda la sezione 103.2.<br />

400001 |#include <br />

400002 |#include <br />

400003 |#include <br />

400004 |#include <br />

400005 |//----------------------------------------------------------------------<br />

400006 |uint16_t<br />

400007 |reverse_16_bit (uint16_t source)<br />

400008 |{<br />

400009 | uint16_t destination = 0;<br />

400010 | uint16_t mask_src;<br />

400011 | uint16_t mask_dst;<br />

400012 | int i;<br />

400013 | for (i = 0; i < 16; i++)<br />

400014 | {<br />

400015 | mask_src = 0x0001 > i;<br />

400017 | if (source & mask_src)<br />

400018 | {<br />

400019 | destination |= mask_dst;<br />

400020 | }<br />

400021 | }<br />

400022 | return (destination);<br />

400023 |}<br />

«<br />

«<br />

«<br />

«<br />

Si veda la sezione 103.2.<br />

360001 |#include <br />

360002 |#include <br />

360003 |#include <br />

360004 |//----------------------------------------------------------------------<br />

360005 |void<br />

360006 |print_segments (void)<br />

360007 |{<br />

360008 | k_printf ("CS=%04x DS=%04x SS=%04x ES=%04x BP=%04x SP=%04x ",<br />

360009 | cs (), ds (), ss (), es (), bp (), sp ());<br />

360010 | k_printf ("heap_min=%04x", heap_min ());<br />

360011 |}<br />

104.3.27 kernel/diag/print_superblock.c<br />

Si veda la sezione 103.2.<br />

370001 |#include <br />

370002 |#include <br />

370003 |#include <br />

370004 |//----------------------------------------------------------------------<br />

370005 |void<br />

370006 |print_superblock (sb_t *sb)<br />

370007 |{<br />

370008 | k_printf ("Inodes: %i\n", sb->inodes);<br />

370009 | k_printf ("Blocks: %i\n", sb->zones);<br />

370010 | k_printf ("First data zone: %i\n", sb->first_data_zone);<br />

370011 | k_printf ("Zone size: %i\n", (1024 log2_size_zone));<br />

370012 | k_printf ("Max file size: %li\n", sb->max_file_size);<br />

370013 | k_printf ("Inode map blocks: %i\n", sb->map_inode_blocks);<br />

370014 | k_printf ("Zone map blocks: %i\n", sb->map_zone_blocks);<br />

370015 |}<br />

104.3.28 kernel/diag/print_time.c<br />

Si veda la sezione 103.2.<br />

380001 |#include <br />

380002 |#include <br />

380003 |#include <br />

380004 |//----------------------------------------------------------------------<br />

380005 |void<br />

380006 |print_time (void)<br />

380007 |{<br />

380008 | unsigned long int ticks = k_clock ();<br />

380009 | unsigned long int seconds = k_time (NULL);<br />

380010 | unsigned int h = seconds / 60 / 60;<br />

380011 | unsigned int m = seconds / 60 - h * 60;<br />

380012 | unsigned int s = seconds - m * 60 - h * 60 * 60;<br />

380013 | k_printf ("clock=%08lx, time elapsed=%02u:%02u:%02u",<br />

380014 | ticks, h, m, s);<br />

380015 |}<br />

104.3.31 kernel/diag/reverse_32_bit.c<br />

Si veda la sezione 103.2.<br />

410001 |#include <br />

410002 |#include <br />

410003 |#include <br />

410004 |//----------------------------------------------------------------------<br />

410005 |uint32_t<br />

410006 |reverse_32_bit (uint32_t source)<br />

410007 |{<br />

410008 | uint32_t destination = 0;<br />

410009 | uint32_t mask_src;<br />

410010 | uint32_t mask_dst;<br />

410011 | int i;<br />

410012 | for (i = 0; i < 32; i++)<br />

410013 | {<br />

410014 | mask_src = 0x00000001 > i;<br />

410016 | if (source & mask_src)<br />

410017 | {<br />

410018 | destination |= mask_dst;<br />

410019 | }<br />

410020 | }<br />

410021 | return (destination);<br />

410022 |}<br />

104.3.32 kernel/diag/reverse_8_bit.c<br />

Si veda la sezione 103.2.<br />

420001 |#include <br />

420002 |#include <br />

420003 |#include <br />

420004 |#include <br />

420005 |//----------------------------------------------------------------------<br />

420006 |uint8_t<br />

420007 |reverse_8_bit (uint8_t source)<br />

420008 |{<br />

420009 | uint8_t destination = 0;<br />

420010 | uint8_t mask_src;<br />

420011 | uint8_t mask_dst;<br />

420012 | int i;<br />

420013 | for (i = 0; i < 8; i++)<br />

420014 | {<br />

420015 | mask_src = 0x01 > i;<br />

420017 | if (source & mask_src)<br />

420018 | {<br />

420019 | destination |= mask_dst;<br />

420020 | }<br />

420021 | }<br />

420022 | return (destination);<br />

420023 |}<br />

«<br />

«<br />

«<br />

104.3.29 kernel/diag/print_zone_map.c<br />

Si veda la sezione 103.2.<br />

390001 |#include <br />

390002 |#include <br />

390003 |#include <br />

390004 |//----------------------------------------------------------------------<br />

390005 |void<br />

390006 |print_zone_map (sb_t *sb, uint16_t *bitmap)<br />

390007 |{<br />

390008 | size_t size;<br />

390009 | unsigned int data_zones = sb->zones - sb->first_data_zone;<br />

390010 | if (data_zones % 16)<br />

390011 | {<br />

390012 | size = data_zones/16 + 1;<br />

390013 | }<br />

390014 | else<br />

390015 | {<br />

390016 | size = data_zones/16;<br />

390017 | }<br />

390018 | print_hex_16_reverse (bitmap, size);<br />

390019 |}<br />

104.4 os16: «kernel/fs.h»<br />

Si veda la sezione 103.3.<br />

430001 |#ifndef _KERNEL_FS_H<br />

430002 |#define _KERNEL_FS_H 1<br />

430003 |<br />

430004 |#include <br />

430005 |#include <br />

430006 |#include <br />

430007 |#include <br />

430008 |#include <br />

430009 |#include <br />

430010 |#include <br />

430011 |#include <br />

430012 |#include <br />

430013 |<br />

430014 |//----------------------------------------------------------------------<br />

430015 |#define SB_MAX_INODE_BLOCKS 1 // 8192 inodes max.<br />

430016 |#define SB_MAX_ZONE_BLOCKS 1 // 8192 data-zones max.<br />

430017 |#define SB_BLOCK_SIZE 1024 // Fixed for Minix file system.<br />

430018 |#define SB_MAX_ZONE_SIZE 2048 // log2 max is 1.<br />

430019 |#define SB_MAP_INODE_SIZE (SB_MAX_INODE_BLOCKS*512) // [1]<br />

430020 |#define SB_MAP_ZONE_SIZE (SB_MAX_ZONE_BLOCKS*512) // [1]<br />

430021 |//<br />

430022 |// [1] blocks * (1024 * 8 / 16) = number of bits, divided 16.<br />

430023 |//<br />

430024 |//----------------------------------------------------------------------<br />

430025 |#define INODE_MAX_INDIRECT_ZONES (SB_MAX_ZONE_SIZE/2) // [2]<br />

430026 |<br />

«

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!