Writing ATA driver LBA28 messed with LBA48 - size

I'm currently trying to get LBA working for my ATA driver, but I have problem.
My identify function returns OK and word 83;bit 10 of returned identification data is set, so my device supports LBA48. But when I try to get total amount of LBA48 sectors (configuration words 100-103), it gives my zero. In virtual machine I have 1GB disk set, but this field is still zero. I also tried to get amount of LBA28 sectors => it's the correct one.
Interesting is that when I print out heads * cylinders * sectors_per_track, the value is almost same as value of total LBA28 sectors located on words 60-61. It's 2097152 for total LBA28 and 2096640 for h * c * s. Difference of these two values is 512.
Does anybody know what am I doing wrong?
Is there any other way for getting the size of HDD?

Related

HID Power Device specification example doesn't indicate values

I'm trying to report battery information for a battery-powered HID device (USB when plugged, BLE otherwise). Reading through the report descriptor from the example in Appendix A of Usage Tables for HID Power Devices (v1.1) I see two collections for reporting data about the battery to the host:
UsagePage(Power Device), Unit(none),
Usage(PresentStatus), Collection(Logical), ; Present status collection
Usage(Good),
UsagePage(Battery System), Usage(BelowRemainingCapacityLimit),
Usage(Charging), Usage(Discharging),
ReportSize(1), ReportCount(4), Logical Minimum (0), Logical Maximum (1), Unit(0),
Feature(Constant, Variable, Absolute, Volatile),
End Collection(), ; End of Present Status collection
UsagePage(Power Device),
Usage(ChangedStatus), Collection(Logical), ; Changed Status collection
Usage(Good),
UsagePage(Battery System), Usage(BelowRemainingCapacityLimit),
Usage(Charging), Usage(Discharging),
ReportSize(2), ReportCount(4), Logical Minimum (0), Logical Maximum (1),
Input(Data, Variable, Absolute, Volatile),
End Collection(), ; End of Changed Status collection
I only have a LiPo battery and a diode to charge it, so I am planning on taking out much of the rest of the power device stuff since I think I can get everything I want from the Battery System usage page. As a result I am looking at something more like (feel free to tell me if this is doomed form the start):
UsagePage(Battery System), Usage(BelowRemainingCapacityLimit),
Usage(Charging), Usage(Discharging),
ReportSize(1), ReportCount(3), Logical Minimum (0), Logical Maximum (1), Unit(0),
Feature(Constant, Variable, Absolute, Volatile),
Looking at the report from the spec, I have two questions:
Why is CapacityMode only size 1? The values are 0 - 3, isn't that a size 2?
What actually goes into the ChangedStatus collection? I see that the report sizes are 2 instead of 1 - are the reporting the old status on there as well? I'm not seeing anything elsewhere in the spec that gives an indication. In fact, the spec says that ChangedStatus elements should be boolean, which should be size 1, no?
CapacityMode can have values 0 to 3, but if your device only supports mode 0 (capacity measured in milliamp-hours) or mode 1 (capacity measured in milliwatt-hours) then I think it is ok to have a 1-bit wide field to record this. You could even define an 8-bit field that only stores the values 0 or 1 even though it could hold values up to 255.
I think the authors of the examples may have been trying to align the fields into 8 bits by making each of the 4 status bits 2-bits wide - so 0, would be stored as 00 and 1 would be stored as 01 in the report. Or it could have been a typo - I have seen many other examples in the USB specifications that have errors in them.

Effective Access Time

I am given the following question:
Now assume the system has no page faults, we are considering adding a TLB that will take
1 nano-second to lookup an address translation. What hit rate (to the nearest 5%) in the TLB is required
to reduce the effective access time to memory by a factor of 2.5?
I am told an average memory access takes 100ns. Since there are 4 memory accesses for a 3 level PT (3 for the page table 1 for physical memory) I deduced that it takes 400ns.
I am then asked to reduce that by a factor of 2.5. So (2/5) *400 = 160ns.
my goal EAT is 160ns. I started setting up the problem and I can't figure out where to go from here.
I am given the following solution but I am just unable to follow it:
Access time = 100 X + (1-x) 400 – 100 ns for hit (read memory), 400ns for
miss
160 = 100 x + 400 – 400x -> x = .8 -> 80% TLB hit rate
Can someone explain to me how they got to this step? I thought EAT was p(time it takes for a hit) + 1-p(time it takes for a miss) where p is the hit rate. isn't the time it takes for a hit 300ns? and then time it takes for a miss is 400ns?
from my logic I tried: p(300) + ((1-p) (400)) but when I went to compute it, I did not get the correct setup as the solution. Can someone explain where my logic is going wrong? Am I wrong about how many memory accesses a hit takes?

What is the unit for SoftLayer_Virtual_Guest:getBandwidthDataByDate

Do you know what is the unit for SoftLayer_Virtual_Guest:getBandwidthDataByDate?
Bit, byte or Octect?
I found some mismatching between the return value from API and portal.
Thanks.
The method that you are using will return an "average: bandwith usage, but the portal uses another method which returns a "sum" value. So the values will not be the same, but they will nearly.
Another thing to point out is that the API does not return bytes/per second, it returns the bytes used by the interface in a peiod of time. what I can see in your result of the api is that period of time is 5 minutes.
so let's convert the data with that information:
646793.0 bytes in 5 minutes
converting to bytes per second (5 minutes = 300 seconds)
646793.0/300 = 2155.976 bytes/second
converting to bits
2155.976 * 8 = 17247.808
converting to kilo bits (note we are not using 1024 )
17247.808 / 1000 = 17.247 KB/s
As I told you the value is closer, but not the same due to the method used if you are looking the exact value you have to use the getSummaryData method. here an example in java Getting bandWidth data in SL
Regards
If I'm not wrong, it is in bytes per second.
Here I added an example for April's question.
Portal Bandwidth Graph
I got the datas by SoftLayer_Virtual_Guest:getBandwidthDataByDate.
getBandwidthDataByDate's output
It showed that 'counter': 646793.0, if the "unit" is bytes per sec, 646793.0Bps*8/1024 != 16.62Kbps

Reading incorrect temperature value from thermistor using EVK1100

I want to get the temperature from a thermistor, so I made a voltage divider (3.3V to 10k resistor and between ground a 10k thermistor) I read the ADC between the 10k resistor and the thermistor.
The BCOEFFICIENT is 3977, the NOMINAL TEMPERATURE is 25C and I use the simple B parameter equation. I'm not sure where I'm doing mistake, I read room temperature as 10.5C which was suppose to be around 24C. The following is the part of the program that I used for temperature sensor(developed in AVR studio),
#define TEMPERATURENOMINAL 25
#define TERMISTORNOMINAL 10000
#define BCOEFFICIENT 3977
#define SERIESRESISTOR 10000
{
float ke1,tempa,xin
ke1 = adc_get_value(peak_adc2,peak2);
xin=(1023/ke1)-1;
xin=SERIESRESISTOR/xin;
tempa=xin/TERMISTORNOMINAL;
tempa=log(tempa);
tempa/= BCOEFFICIENT;
tempa+=1.0/(TEMPERATURENOMINAL + 273.15);
tempa=1.0/tempa;
tempa-=273.15;
dip204_set_cursor_position(1,3);
//sprintf(ui, "Temp is %.2f deg", Ref);
sprintf(ui, "Temp is %.2f deg", tempa);
dip204_write_string(ui);
}
I checked the voltage using multi-meter for instance in between the thermistor and 10k resistor and in the EVK 1100 using the following line
ke1 = adc_get_value(peak_adc2,peak2)*3.3/1024;
I get the same voltage in both.
Not sure where I'm doing a mistake, Hope someone guide me in right direction
Your code looks correct to me, and I suspect a hardware problem may be the culprit.
It seems likely you have inadvertently connected two 10K-ohm pull-up resistors between the ADC input and the +3.3V reference: perhaps one is already populated on the EVK1100 board, and you have added another one externally connected to your thermistor. This would be equivalent to putting both 10K-ohm resistors in parallel with each other, which would be equivalent to a 5K-ohm resistor in series with the thermistor. At 25°C, the thermistor resistance Rt would read 10K ohms, which would produce a voltage of:
+3.3V * (Rt / (Rt + 5K))
= 2.20V
instead of the correct +1.65V. This number is very close to the result you are seeing (+2.17V # 24°C).
You can verify this hypothesis by looking at the schematic and/or PCB for the EVK1100 to see if a 10K-ohm pull-up resistor is connected from the ADC input to +3.3V. If this is the problem, remove one of the two resistors and you should see correct behavior.

Calculating the size of a page table

I have an assignment with the following prompt:
The page size for a virtual memory system is 8KB.
The instruction TLB is direct-mapped with 2 sets and each block contains one translation.
^(I don't believe this is relevant for the following 3 questions, as there are two more questions about the TLB)
The number of bits in a virtual address is 20.
The number of bits in a physical address is 15.
(1) What is the number of virtual pages?
I think I have this one figured out.
Page size = 8 * 2^10 = 8192, so the offset is 13 bits.
Virtual page number = 20 - 13 = 7 bits
Virtual pages = 2^7 pages
(2) What is the number of physical pages?
Here's where I'm a little confused. I think I'm supposed to add in the valid, dirty, and reference bits to the physical page number (which is 2, from 15 - 13). However 5 * 2^7 = 640 bytes, which seems incredibly small.
(3) How many bits are used in the virtual address for the page offset?
Answered above, it appears to be 13 bits.
Could anyone point me in the right direction? Thanks!
The valid, dirty, and reference bits are in a page table entry but are not part of the address bits. Therefore using your results there are 2^2 or 4 physical pages.
Yes this does seem small, but realize that there is only 2^15 or 32K bytes of physical memory.